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

Function TestAppendBytesHeader

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

Source from the content-addressed store, hash-verified

97}
98
99func TestAppendBytesHeader(t *testing.T) {
100 szs := []uint32{0, 1, uint32(tint8), uint32(tint16), tuint32, math.MaxUint32}
101 var buf bytes.Buffer
102 en := NewWriter(&buf)
103
104 var bts []byte
105 for _, sz := range szs {
106 buf.Reset()
107 en.WriteBytesHeader(sz)
108 en.Flush()
109 bts = AppendBytesHeader(bts[0:0], sz)
110
111 if !bytes.Equal(buf.Bytes(), bts) {
112 t.Errorf("for size %d, encoder wrote %q and append wrote %q", sz, buf.Bytes(), bts)
113 }
114 }
115}
116
117func BenchmarkAppendBytesHeader(b *testing.B) {
118 buf := make([]byte, 0, 9)

Callers

nothing calls this directly

Calls 6

WriteBytesHeaderMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
AppendBytesHeaderFunction · 0.85
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…