MCPcopy
hub / github.com/grpc/grpc-go / TestBufferPool

Method TestBufferPool

mem/buffer_pool_test.go:30–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func (s) TestBufferPool(t *testing.T) {
31 var poolSizes = []int{4, 8, 16, 32}
32 pools := []mem.BufferPool{
33 mem.NopBufferPool{},
34 mem.NewTieredBufferPool(poolSizes...),
35 }
36
37 testSizes := append([]int{1}, poolSizes...)
38 testSizes = append(testSizes, 64)
39
40 for _, p := range pools {
41 for _, l := range testSizes {
42 bs := p.Get(l)
43 if len(*bs) != l {
44 t.Fatalf("Get(%d) returned buffer of length %d, want %d", l, len(*bs), l)
45 }
46
47 p.Put(bs)
48 }
49 }
50}
51
52func (s) TestBufferPoolClears(t *testing.T) {
53 const poolSize = 4

Callers

nothing calls this directly

Calls 4

NewTieredBufferPoolFunction · 0.92
GetMethod · 0.65
FatalfMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected