(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestEmptyVarstring31(t *testing.T) { |
| 165 | s := []byte{} |
| 166 | b := new(bytes.Buffer) |
| 167 | _, err := WriteVarstr31(b, s) |
| 168 | if err != nil { |
| 169 | t.Fatal(err) |
| 170 | } |
| 171 | want := []byte{0x00} |
| 172 | if !bytes.Equal(b.Bytes(), want) { |
| 173 | t.Errorf("got %x, want %x", b.Bytes(), want) |
| 174 | } |
| 175 | |
| 176 | s, err = ReadVarstr31(NewReader(want)) |
| 177 | if err != nil { |
| 178 | t.Fatal(err) |
| 179 | } |
| 180 | want = nil // we deliberately return nil for empty strings to avoid unnecessary byteslice allocation |
| 181 | if !bytes.Equal(s, want) { |
| 182 | t.Errorf("got %x, expected %x", s, want) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // TestTooLongVarstring31 tests decoding a varstring31 with a leading |
| 187 | // length too long to fit in memory. Reading such a varstring31 should |
nothing calls this directly
no test coverage detected