ceremonyclient/go-libp2p/p2p/metricshelper/pool_test.go

22 lines
351 B
Go
Raw Normal View History

2023-08-21 03:50:38 +00:00
package metricshelper
import (
"math/rand"
"testing"
"github.com/stretchr/testify/require"
)
func TestStringSlicePool(t *testing.T) {
for i := 0; i < 1e5; i++ {
s := GetStringSlice()
require.Empty(t, *s)
require.Equal(t, 8, cap(*s))
*s = append(*s, "foo")
*s = append(*s, "bar")
if rand.Int()%3 == 0 {
PutStringSlice(s)
}
}
}