MCPcopy
hub / github.com/tinylib/msgp / TestReadComplex64

Function TestReadComplex64

msgp/read_test.go:831–857  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

829}
830
831func TestReadComplex64(t *testing.T) {
832 var buf bytes.Buffer
833 wr := NewWriter(&buf)
834 rd := NewReader(&buf)
835
836 for range 100 {
837 buf.Reset()
838 f := complex(rand.Float32()*math.MaxFloat32, rand.Float32()*math.MaxFloat32)
839
840 wr.WriteComplex64(f)
841 err := wr.Flush()
842 if err != nil {
843 t.Fatal(err)
844 }
845
846 out, err := rd.ReadComplex64()
847 if err != nil {
848 t.Error(err)
849 continue
850 }
851
852 if out != f {
853 t.Errorf("Wrote %f; read %f", f, out)
854 }
855
856 }
857}
858
859func BenchmarkReadComplex64(b *testing.B) {
860 f := complex(rand.Float32(), rand.Float32())

Callers

nothing calls this directly

Calls 7

WriteComplex64Method · 0.95
FlushMethod · 0.95
ReadComplex64Method · 0.95
NewWriterFunction · 0.85
NewReaderFunction · 0.85
ResetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…