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

Function TestAppendBytes

msgp/write_bytes_test.go:312–328  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

310}
311
312func TestAppendBytes(t *testing.T) {
313 sizes := []int{0, 1, 225, int(tuint32)}
314 var buf bytes.Buffer
315 en := NewWriter(&buf)
316 var bts []byte
317
318 for _, sz := range sizes {
319 buf.Reset()
320 b := RandBytes(sz)
321 en.WriteBytes(b)
322 en.Flush()
323 bts = AppendBytes(b[0:0], b)
324 if !bytes.Equal(buf.Bytes(), bts) {
325 t.Errorf("for bytes of length %d, encoder wrote %d bytes and append wrote %d bytes", sz, buf.Len(), len(bts))
326 }
327 }
328}
329
330func benchappendBytes(size uint32, b *testing.B) {
331 bts := RandBytes(int(size))

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…