(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func 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 | } |