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

Function TestReadFloat32Bytes

msgp/read_bytes_test.go:200–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestReadFloat32Bytes(t *testing.T) {
201 var buf bytes.Buffer
202 en := NewWriter(&buf)
203 en.WriteFloat32(3.1)
204 en.Flush()
205
206 out, left, err := ReadFloat32Bytes(buf.Bytes())
207 if err != nil {
208 t.Fatal(err)
209 }
210 if len(left) != 0 {
211 t.Errorf("expected 0 bytes left; found %d", len(left))
212 }
213 if out != 3.1 {
214 t.Errorf("%f in; %f out", 3.1, out)
215 }
216}
217
218func BenchmarkReadFloat32Bytes(b *testing.B) {
219 f := float32(3.14159)

Callers

nothing calls this directly

Calls 4

WriteFloat32Method · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadFloat32BytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…