uquic/buffer_pool_test.go
Marten Seemann 767dbdd545 put back packet buffers after processing a packet
This introduces a reference counter in the packet buffer, which will be
used to process coalesced packets.
2019-01-01 09:50:29 +07:00

32 lines
739 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())
})
})