MCPcopy
hub / github.com/grafana/tempo / TestPoolSlicesAreAlwaysLargeEnough

Function TestPoolSlicesAreAlwaysLargeEnough

pkg/tempopb/pool_test.go:58–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestPoolSlicesAreAlwaysLargeEnough(t *testing.T) {
59 testPool := NewPool("foo", 100, 200, 5)
60
61 for i := 0; i < 10000; i++ {
62 size := rand.Intn(1000)
63 externalSlice := make([]byte, 0, size)
64 testPool.Put(externalSlice)
65
66 size = rand.Intn(1000)
67 ret := testPool.Get(size)
68
69 require.True(t, cap(ret) >= size, "cap: %d, size: %d", cap(ret), size)
70
71 testPool.Put(ret)
72 }
73}
74
75func TestBucketFor(t *testing.T) {
76 testPool := NewPool("foo", 5, 10, 5)

Callers

nothing calls this directly

Calls 3

PutMethod · 0.95
GetMethod · 0.95
NewPoolFunction · 0.70

Tested by

no test coverage detected