Skip to content

Commit 47c756d

Browse files
author
James Cor
committed
test bad byte buffering
1 parent 836da4f commit 47c756d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sql/byte_buffer_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package sql
1616

1717
import (
18+
"fmt"
19+
"strconv"
1820
"testing"
1921

2022
"github.com/stretchr/testify/require"
@@ -70,3 +72,24 @@ func TestGrowByteBuffer(t *testing.T) {
7072
require.Equal(t, 40, len(b.buf))
7173
require.Equal(t, 0, b.i)
7274
}
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

Comments
 (0)