(t *testing.T)
| 5 | import "testing" |
| 6 | |
| 7 | func Test_BufferCapacity(t *testing.T) { |
| 8 | b := NewWString() |
| 9 | |
| 10 | c := b.Cap() |
| 11 | if c < MinWStringCap { |
| 12 | t.Fatalf("expected capacity >= %d, got %d", MinWStringCap, c) |
| 13 | } |
| 14 | |
| 15 | if l := len(b.b); l != int(c) { |
| 16 | t.Fatalf("buffer length (%d) and capacity (%d) mismatch", l, c) |
| 17 | } |
| 18 | |
| 19 | n := uint32(1.5 * MinWStringCap) |
| 20 | nn := b.ResizeTo(n) |
| 21 | if len(b.b) != int(nn) { |
| 22 | t.Fatalf("resized buffer should be %d, was %d", nn, len(b.b)) |
| 23 | } |
| 24 | if n > nn { |
| 25 | t.Fatalf("resized to a value smaller than requested") |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func Test_BufferFree(t *testing.T) { |
| 30 | // make sure free-ing doesn't set pooled buffer to nil as well |
nothing calls this directly
no test coverage detected
searching dependent graphs…