MCPcopy
hub / github.com/uber-go/zap / TestBuffers

Function TestBuffers

buffer/pool_test.go:30–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestBuffers(t *testing.T) {
31 const dummyData = "dummy data"
32 p := NewPool()
33
34 var wg sync.WaitGroup
35 for g := 0; g < 10; g++ {
36 wg.Add(1)
37 go func() {
38 for i := 0; i < 100; i++ {
39 buf := p.Get()
40 assert.Zero(t, buf.Len(), "Expected truncated buffer")
41 assert.NotZero(t, buf.Cap(), "Expected non-zero capacity")
42
43 buf.AppendString(dummyData)
44 assert.Equal(t, buf.Len(), len(dummyData), "Expected buffer to contain dummy data")
45
46 buf.Free()
47 }
48 wg.Done()
49 }()
50 }
51 wg.Wait()
52}

Callers

nothing calls this directly

Calls 7

GetMethod · 0.95
NewPoolFunction · 0.85
CapMethod · 0.80
AppendStringMethod · 0.65
AddMethod · 0.45
LenMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected