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

Function TestReadFloat32

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

Source from the content-addressed store, hash-verified

379}
380
381func TestReadFloat32(t *testing.T) {
382 var buf bytes.Buffer
383 wr := NewWriter(&buf)
384 rd := NewReader(&buf)
385
386 for range 10000 {
387 buf.Reset()
388
389 flt := (rand.Float32() - 0.5) * math.MaxFloat32
390 err := wr.WriteFloat32(flt)
391 if err != nil {
392 t.Fatal(err)
393 }
394 err = wr.Flush()
395 if err != nil {
396 t.Fatal(err)
397 }
398 out, err := rd.ReadFloat32()
399 if err != nil {
400 t.Errorf("Error reading %f: %s", flt, err)
401 continue
402 }
403
404 if out != flt {
405 t.Errorf("Put in %f but got out %f", flt, out)
406 }
407 }
408}
409
410func BenchmarkReadFloat32(b *testing.B) {
411 fs := []float32{rand.Float32(), rand.Float32(), rand.Float32(), rand.Float32()}

Callers

nothing calls this directly

Calls 6

WriteFloat32Method · 0.95
FlushMethod · 0.95
ReadFloat32Method · 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…