MCPcopy Index your code
hub / github.com/tinylib/msgp / TestReadFloat64

Function TestReadFloat64

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

Source from the content-addressed store, hash-verified

332}
333
334func TestReadFloat64(t *testing.T) {
335 var buf bytes.Buffer
336 wr := NewWriter(&buf)
337 rd := NewReader(&buf)
338
339 for range 100 {
340 buf.Reset()
341
342 flt := (rand.Float64() - 0.5) * math.MaxFloat64
343 err := wr.WriteFloat64(flt)
344 if err != nil {
345 t.Fatal(err)
346 }
347 err = wr.Flush()
348 if err != nil {
349 t.Fatal(err)
350 }
351 out, err := rd.ReadFloat64()
352 if err != nil {
353 t.Errorf("Error reading %f: %s", flt, err)
354 continue
355 }
356
357 if out != flt {
358 t.Errorf("Put in %f but got out %f", flt, out)
359 }
360 }
361}
362
363func BenchmarkReadFloat64(b *testing.B) {
364 fs := []float64{rand.Float64(), rand.Float64(), rand.Float64(), rand.Float64()}

Callers

nothing calls this directly

Calls 6

WriteFloat64Method · 0.95
FlushMethod · 0.95
ReadFloat64Method · 0.95
NewWriterFunction · 0.85
NewReaderFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…