micro/util/xpool/pool_test.go
Vasiliy Tolstov 1bcf71c189 util/xpool: package pool
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-04-14 00:16:55 +03:00

28 lines
477 B
Go

package pool
import (
"bytes"
"strings"
"testing"
)
func TestBytes(t *testing.T) {
p := NewPool(func() *bytes.Buffer { return bytes.NewBuffer(nil) })
b := p.Get()
b.Write([]byte(`test`))
if b.String() != "test" {
t.Fatal("pool not works")
}
p.Put(b)
}
func TestStrings(t *testing.T) {
p := NewPool(func() *strings.Builder { return &strings.Builder{} })
b := p.Get()
b.Write([]byte(`test`))
if b.String() != "test" {
t.Fatal("pool not works")
}
p.Put(b)
}