github.com/viant/toolbox@v0.34.5/bridge/byte_buffer_pool_test.go (about) 1 package bridge_test 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "github.com/viant/toolbox" 6 "testing" 7 ) 8 9 func TestNewBytesBufferPool(t *testing.T) { 10 pool := toolbox.NewBytesBufferPool(2, 1024) 11 buf := pool.Get() //creates a new buffer pool is empty. 12 assert.NotNil(t, buf) 13 14 buf[1] = 0x2 15 pool.Put(buf) 16 pool.Put([]byte{0x1}) 17 pool.Put(buf) //get discarded 18 { 19 poolBuf := pool.Get() 20 assert.Equal(t, uint8(0x2), poolBuf[1]) 21 assert.Equal(t, 1024, len(poolBuf)) 22 } 23 { 24 poolBuf := pool.Get() 25 assert.Equal(t, 1, len(poolBuf)) 26 } 27 }