(t *testing.T)
| 99 | } |
| 100 | |
| 101 | func 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 | |
| 127 | func BenchmarkTestReadBytesHeader(b *testing.B) { |
| 128 | sizes := []uint32{1, 100, tuint16, tuint32} |
nothing calls this directly
no test coverage detected
searching dependent graphs…