|
15 | 15 | package sql |
16 | 16 |
|
17 | 17 | import ( |
| 18 | + "fmt" |
| 19 | + "strconv" |
18 | 20 | "testing" |
19 | 21 |
|
20 | 22 | "github.com/stretchr/testify/require" |
@@ -70,3 +72,24 @@ func TestGrowByteBuffer(t *testing.T) { |
70 | 72 | require.Equal(t, 40, len(b.buf)) |
71 | 73 | require.Equal(t, 0, b.i) |
72 | 74 | } |
| 75 | + |
| 76 | +func TestByteBufferDoubling(t *testing.T) { |
| 77 | + bb := NewByteBuffer(5) |
| 78 | + fmt.Printf("bb.buf: %v, cap: %d\n", bb.buf, cap(bb.buf)) |
| 79 | + fmt.Printf("bb.i: %v\n", bb.i) |
| 80 | + |
| 81 | + i0 := bb.Get() |
| 82 | + i0 = strconv.AppendInt(i0, 12345, 10) |
| 83 | + bb.Grow(len(i0)) |
| 84 | + fmt.Printf("i0: %v, cap: %d\n", i0, cap(i0)) |
| 85 | + fmt.Printf("bb.buf: %v, cap: %d\n", bb.buf, cap(bb.buf)) |
| 86 | + fmt.Printf("bb.i: %v\n", bb.i) |
| 87 | + |
| 88 | + i5 := bb.Get() |
| 89 | + i5 = strconv.AppendInt(i5, 678901, 10) |
| 90 | + bb.Grow(len(i5)) |
| 91 | + fmt.Printf("i0: %v, cap: %d\n", i0, cap(i0)) |
| 92 | + fmt.Printf("i5: %v, cap: %d\n", i5, cap(i5)) |
| 93 | + fmt.Printf("bb.buf: %v, cap: %d\n", bb.buf, cap(bb.buf)) |
| 94 | + fmt.Printf("bb.i: %v\n", bb.i) |
| 95 | +} |
0 commit comments