implement PingFrame

This commit is contained in:
Marten Seemann
2016-05-04 10:08:07 +07:00
parent b183b0edb3
commit 01c5d91acc
5 changed files with 72 additions and 5 deletions

33
frames/ping_frame_test.go Normal file
View File

@@ -0,0 +1,33 @@
package frames
import (
"bytes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("PingFrame", func() {
Context("when parsing", func() {
It("accepts sample frame", func() {
b := bytes.NewReader([]byte{0x07})
_, err := ParsePingFrame(b)
Expect(err).ToNot(HaveOccurred())
Expect(b.Len()).To(Equal(0))
})
})
Context("when writing", func() {
It("writes a sample frame", func() {
b := &bytes.Buffer{}
frame := PingFrame{}
frame.Write(b, 10, 6)
Expect(b.Bytes()).To(Equal([]byte{0x07}))
})
It("has the correct min length", func() {
frame := PingFrame{}
Expect(frame.MinLength()).To(Equal(1))
})
})
})