You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
591 B
32 lines
591 B
package core
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestBuffers(t *testing.T) {
|
|
const dummyData = "dummy data"
|
|
p := NewPool(0)
|
|
|
|
var wg sync.WaitGroup
|
|
for g := 0; g < 10; g++ {
|
|
wg.Add(1)
|
|
go func() {
|
|
for i := 0; i < 100; i++ {
|
|
buf := p.Get()
|
|
assert.Zero(t, buf.Len(), "Expected truncated buffer")
|
|
assert.NotZero(t, buf.Cap(), "Expected non-zero capacity")
|
|
|
|
buf.AppendString(dummyData)
|
|
assert.Equal(t, buf.Len(), len(dummyData), "Expected buffer to contain dummy data")
|
|
|
|
buf.Free()
|
|
}
|
|
wg.Done()
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
}
|
|
|