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

Function TestReadBytesHeader

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

Source from the content-addressed store, hash-verified

99}
100
101func TestReadBytesHeader(t *testing.T) {
102 var buf bytes.Buffer
103 en := NewWriter(&buf)
104
105 tests := []uint32{0, 1, 5, 49082, 1 << 16, math.MaxUint32}
106
107 for i, v := range tests {
108 buf.Reset()
109 en.WriteBytesHeader(v)
110 en.Flush()
111
112 out, left, err := ReadBytesHeader(buf.Bytes())
113 if err != nil {
114 t.Errorf("test case %d: %s", i, err)
115 }
116
117 if len(left) != 0 {
118 t.Errorf("expected 0 bytes left; found %d", len(left))
119 }
120
121 if out != v {
122 t.Errorf("%d in; %d out", v, out)
123 }
124 }
125}
126
127func BenchmarkTestReadBytesHeader(b *testing.B) {
128 sizes := []uint32{1, 100, tuint16, tuint32}

Callers

nothing calls this directly

Calls 5

WriteBytesHeaderMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadBytesHeaderFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…