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

Function TestWriteFloat64

msgp/write_test.go:196–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestWriteFloat64(t *testing.T) {
197 var buf bytes.Buffer
198 wr := NewWriter(&buf)
199
200 for range 10000 {
201 buf.Reset()
202 flt := (rand.Float64() - 0.5) * math.MaxFloat64
203 err := wr.WriteFloat64(flt)
204 if err != nil {
205 t.Errorf("Error with %f: %s", flt, err)
206 }
207 err = wr.Flush()
208 if err != nil {
209 t.Fatal(err)
210 }
211
212 bts := buf.Bytes()
213
214 if bts[0] != mfloat64 {
215 t.Errorf("Leading byte was %x and not %x", bts[0], mfloat64)
216 }
217 }
218}
219
220func TestReadWriterDuration(t *testing.T) {
221 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…