(t *testing.T)
| 345 | func BenchmarkAppend2048Bytes(b *testing.B) { benchappendBytes(2048, b) } |
| 346 | |
| 347 | func TestAppendString(t *testing.T) { |
| 348 | sizes := []int{0, 1, 225, int(tuint32)} |
| 349 | var buf bytes.Buffer |
| 350 | en := NewWriter(&buf) |
| 351 | var bts []byte |
| 352 | |
| 353 | for _, sz := range sizes { |
| 354 | buf.Reset() |
| 355 | s := string(RandBytes(sz)) |
| 356 | en.WriteString(s) |
| 357 | en.Flush() |
| 358 | bts = AppendString(bts[0:0], s) |
| 359 | if !bytes.Equal(buf.Bytes(), bts) { |
| 360 | t.Errorf("for string of length %d, encoder wrote %d bytes and append wrote %d bytes", sz, buf.Len(), len(bts)) |
| 361 | t.Errorf("WriteString prefix: %x", buf.Bytes()[0:5]) |
| 362 | t.Errorf("Appendstring prefix: %x", bts[0:5]) |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | func benchappendString(size uint32, b *testing.B) { |
| 368 | str := string(RandBytes(int(size))) |
nothing calls this directly
no test coverage detected
searching dependent graphs…