MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestFuzzyByteSlicePools

Function TestFuzzyByteSlicePools

pkg/cortexpb/slicesPool_test.go:11–21  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestFuzzyByteSlicePools(t *testing.T) {
12 sut := newSlicePool(20)
13 maxByteSize := int(math.Pow(2, 20+minPoolSizePower-1))
14
15 for range 1000 {
16 size := rand.Int() % maxByteSize
17 s := sut.getSlice(size)
18 assert.Equal(t, len(*s), size)
19 sut.reuseSlice(s)
20 }
21}
22
23func TestReturnSliceSmallerThanMin(t *testing.T) {
24 sut := newSlicePool(20)

Callers

nothing calls this directly

Calls 4

newSlicePoolFunction · 0.85
getSliceMethod · 0.80
reuseSliceMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected