File size: 379 Bytes
ca7217f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package bufferpool

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestBufferPool(t *testing.T) {
	const size = 1024
	bp := New(size)
	for i := 0; i < 10; i++ {
		buf := bp.Get()
		assert.NotNil(t, buf)
		assert.Equal(t, buf.Len(), 0)
		assert.GreaterOrEqual(t, buf.Cap(), size)
		buf.WriteString(strings.Repeat("\x00", size*2))
		bp.Put(buf)
	}
}