mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
43 lines
1,004 B
Go
43 lines
1,004 B
Go
package quic
|
|
|
|
import (
|
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Buffer Pool", func() {
|
|
It("returns buffers of cap", func() {
|
|
buf := getPacketBuffer()
|
|
Expect(buf.Slice).To(HaveCap(int(protocol.MaxReceivePacketSize)))
|
|
})
|
|
|
|
It("puts buffers back", func() {
|
|
buf := getPacketBuffer()
|
|
putPacketBuffer(buf)
|
|
})
|
|
|
|
It("panics if wrong-sized buffers are passed", func() {
|
|
buf := getPacketBuffer()
|
|
buf.Slice = make([]byte, 10)
|
|
Expect(func() { putPacketBuffer(buf) }).To(Panic())
|
|
})
|
|
|
|
It("panics if it is put pack twice", func() {
|
|
buf := getPacketBuffer()
|
|
putPacketBuffer(buf)
|
|
Expect(func() { putPacketBuffer(buf) }).To(Panic())
|
|
})
|
|
|
|
It("waits until all parts have been put back", func() {
|
|
buf := getPacketBuffer()
|
|
buf.Split()
|
|
buf.Split()
|
|
// now we have 3 parts
|
|
putPacketBuffer(buf)
|
|
putPacketBuffer(buf)
|
|
putPacketBuffer(buf)
|
|
Expect(func() { putPacketBuffer(buf) }).To(Panic())
|
|
})
|
|
})
|