route/vendor/github.com/lucas-clemente/quic-go/buffer_pool_test.go

33 lines
746 B
Go
Raw Normal View History

2017-12-12 02:51:45 +00:00
package quic
import (
2018-01-03 19:19:49 +00:00
"github.com/lucas-clemente/quic-go/internal/protocol"
2017-12-12 02:51:45 +00:00
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Buffer Pool", func() {
It("returns buffers of correct len and cap", func() {
buf := getPacketBuffer()
Expect(buf).To(HaveLen(0))
Expect(buf).To(HaveCap(int(protocol.MaxReceivePacketSize)))
})
It("zeroes put buffers' length", func() {
for i := 0; i < 1000; i++ {
buf := getPacketBuffer()
putPacketBuffer(buf[0:10])
buf = getPacketBuffer()
Expect(buf).To(HaveLen(0))
Expect(buf).To(HaveCap(int(protocol.MaxReceivePacketSize)))
}
})
It("panics if wrong-sized buffers are passed", func() {
Expect(func() {
putPacketBuffer([]byte{0})
}).To(Panic())
})
})