TestTooLongVarstring31 tests decoding a varstring31 with a leading length too long to fit in memory. Reading such a varstring31 should not try to allocate more memory than feasible.
(t *testing.T)
| 187 | // length too long to fit in memory. Reading such a varstring31 should |
| 188 | // not try to allocate more memory than feasible. |
| 189 | func TestTooLongVarstring31(t *testing.T) { |
| 190 | var buf bytes.Buffer |
| 191 | WriteVarint31(&buf, 0x7fffffff) |
| 192 | buf.Write([]byte{0x01, 0x02, 0x03}) |
| 193 | |
| 194 | _, err := ReadVarstr31(NewReader(buf.Bytes())) |
| 195 | if err != io.ErrUnexpectedEOF { |
| 196 | t.Errorf("got %s, want io.ErrUnexpectedEOF", err) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | func TestVarstrList(t *testing.T) { |
| 201 | for i := 0; i < 4; i++ { |
nothing calls this directly
no test coverage detected