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

Function TestWriteBytes

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

Source from the content-addressed store, hash-verified

364}
365
366func TestWriteBytes(t *testing.T) {
367 var buf bytes.Buffer
368 wr := NewWriter(&buf)
369 sizes := []int{0, 1, 225, int(tuint32)}
370
371 for _, size := range sizes {
372 buf.Reset()
373 bts := RandBytes(size)
374
375 err := wr.WriteBytes(bts)
376 if err != nil {
377 t.Fatal(err)
378 }
379
380 err = wr.Flush()
381 if err != nil {
382 t.Fatal(err)
383 }
384
385 if buf.Len() < len(bts) {
386 t.Errorf("somehow, %d bytes were encoded in %d bytes", len(bts), buf.Len())
387 }
388 }
389}
390
391func benchwrBytes(size uint32, b *testing.B) {
392 bts := RandBytes(int(size))

Callers

nothing calls this directly

Calls 6

WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
RandBytesFunction · 0.85
LenMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…