MCPcopy
hub / github.com/jackc/pgx / TestPutGetBufferReuse

Function TestPutGetBufferReuse

internal/iobufpool/iobufpool_test.go:71–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

69}
70
71func TestPutGetBufferReuse(t *testing.T) {
72 // There is no way to guarantee a buffer will be reused. It should be, but a GC between the Put and the Get will cause
73 // it not to be. So try many times.
74 for range 100_000 {
75 buf := iobufpool.Get(4)
76 (*buf)[0] = 1
77 iobufpool.Put(buf)
78 buf = iobufpool.Get(4)
79 if (*buf)[0] == 1 {
80 return
81 }
82 }
83
84 t.Error("buffer was never reused")
85}

Callers

nothing calls this directly

Calls 3

GetFunction · 0.92
PutFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected