forked from quic-go/quic-go
add a buffer pool test for wrong-sized puts
This commit is contained in:
@@ -14,7 +14,6 @@ func getPacketBuffer() []byte {
|
|||||||
|
|
||||||
func putPacketBuffer(buf []byte) {
|
func putPacketBuffer(buf []byte) {
|
||||||
if cap(buf) != int(protocol.MaxPacketSize) {
|
if cap(buf) != int(protocol.MaxPacketSize) {
|
||||||
println(buf)
|
|
||||||
panic("putPacketBuffer called with packet of wrong size!")
|
panic("putPacketBuffer called with packet of wrong size!")
|
||||||
}
|
}
|
||||||
bufferPool.Put(buf[:0])
|
bufferPool.Put(buf[:0])
|
||||||
|
|||||||
@@ -23,4 +23,10 @@ var _ = Describe("Buffer Pool", func() {
|
|||||||
Expect(buf).To(HaveCap(int(protocol.MaxPacketSize)))
|
Expect(buf).To(HaveCap(int(protocol.MaxPacketSize)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("panics if wrong-sized buffers are passed", func() {
|
||||||
|
Expect(func() {
|
||||||
|
putPacketBuffer([]byte{0})
|
||||||
|
}).To(Panic())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user