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

Method TestBuffer_RefAfterFree

mem/buffers_test.go:226–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

224}
225
226func (s) TestBuffer_RefAfterFree(t *testing.T) {
227 // Verify that acquiring a ref before freeing does not panic.
228 buf := newBuffer([]byte("abcd"), mem.NopBufferPool{})
229 buf.Ref()
230
231 // This first call should not panic and bring the ref counter down to 1
232 buf.Free()
233 // This second call actually frees the buffer
234 buf.Free()
235 defer checkForPanic(t, "Cannot ref freed buffer")
236 buf.Ref()
237}
238
239func (s) TestBuffer_SplitAfterFree(t *testing.T) {
240 // Verify that splitting before freeing does not panic.

Callers

nothing calls this directly

Calls 4

checkForPanicFunction · 0.85
newBufferFunction · 0.70
RefMethod · 0.65
FreeMethod · 0.65

Tested by

no test coverage detected