MCPcopy Index your code
hub / github.com/tinylib/msgp / TestWriteMapHeader

Function TestWriteMapHeader

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

Source from the content-addressed store, hash-verified

28}
29
30func TestWriteMapHeader(t *testing.T) {
31 tests := []struct {
32 Sz uint32
33 Outbytes []byte
34 }{
35 {0, []byte{mfixmap}},
36 {1, []byte{mfixmap | byte(1)}},
37 {100, []byte{mmap16, byte(uint16(100) >> 8), byte(uint16(100))}},
38 {
39 tuint32,
40 []byte{
41 mmap32,
42 byte(tuint32 >> 24),
43 byte(tuint32 >> 16),
44 byte(tuint32 >> 8),
45 byte(tuint32),
46 },
47 },
48 }
49
50 var buf bytes.Buffer
51 var err error
52 wr := NewWriter(&buf)
53 for _, test := range tests {
54 buf.Reset()
55 err = wr.WriteMapHeader(test.Sz)
56 if err != nil {
57 t.Error(err)
58 }
59 err = wr.Flush()
60 if err != nil {
61 t.Fatal(err)
62 }
63 if !bytes.Equal(buf.Bytes(), test.Outbytes) {
64 t.Errorf("Expected bytes %x; got %x", test.Outbytes, buf.Bytes())
65 }
66 }
67}
68
69func BenchmarkWriteMapHeader(b *testing.B) {
70 wr := NewWriter(Nowhere)

Callers

nothing calls this directly

Calls 6

WriteMapHeaderMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ResetMethod · 0.45
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…