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

Function TestReadMapHeaderBytes

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

Source from the content-addressed store, hash-verified

11)
12
13func TestReadMapHeaderBytes(t *testing.T) {
14 var buf bytes.Buffer
15 en := NewWriter(&buf)
16
17 tests := []uint32{0, 1, 5, 49082}
18
19 for i, v := range tests {
20 buf.Reset()
21 en.WriteMapHeader(v)
22 en.Flush()
23
24 out, left, err := ReadMapHeaderBytes(buf.Bytes())
25 if err != nil {
26 t.Errorf("test case %d: %s", i, err)
27 }
28
29 if len(left) != 0 {
30 t.Errorf("expected 0 bytes left; found %d", len(left))
31 }
32
33 if out != v {
34 t.Errorf("%d in; %d out", v, out)
35 }
36 }
37}
38
39func BenchmarkReadMapHeaderBytes(b *testing.B) {
40 sizes := []uint32{1, 100, tuint16, tuint32}

Callers

nothing calls this directly

Calls 5

WriteMapHeaderMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadMapHeaderBytesFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…