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

Function TestReadComplex128

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

Source from the content-addressed store, hash-verified

872}
873
874func TestReadComplex128(t *testing.T) {
875 var buf bytes.Buffer
876 wr := NewWriter(&buf)
877 rd := NewReader(&buf)
878
879 for range 10 {
880 buf.Reset()
881 f := complex(rand.Float64()*math.MaxFloat64, rand.Float64()*math.MaxFloat64)
882
883 wr.WriteComplex128(f)
884 err := wr.Flush()
885 if err != nil {
886 t.Fatal(err)
887 }
888
889 out, err := rd.ReadComplex128()
890 if err != nil {
891 t.Error(err)
892 continue
893 }
894 if out != f {
895 t.Errorf("Wrote %f; read %f", f, out)
896 }
897
898 }
899}
900
901func BenchmarkReadComplex128(b *testing.B) {
902 f := complex(rand.Float64(), rand.Float64())

Callers

nothing calls this directly

Calls 7

WriteComplex128Method · 0.95
FlushMethod · 0.95
ReadComplex128Method · 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…