summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gorilla/websocket/conn_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gorilla/websocket/conn_test.go')
-rw-r--r--vendor/github.com/gorilla/websocket/conn_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/github.com/gorilla/websocket/conn_test.go b/vendor/github.com/gorilla/websocket/conn_test.go
index 7431383b1..06e9bc3f5 100644
--- a/vendor/github.com/gorilla/websocket/conn_test.go
+++ b/vendor/github.com/gorilla/websocket/conn_test.go
@@ -463,3 +463,35 @@ func TestFailedConnectionReadPanic(t *testing.T) {
}
t.Fatal("should not get here")
}
+
+func TestBufioReuse(t *testing.T) {
+ brw := bufio.NewReadWriter(bufio.NewReader(nil), bufio.NewWriter(nil))
+ c := newConnBRW(nil, false, 0, 0, brw)
+
+ if c.br != brw.Reader {
+ t.Error("connection did not reuse bufio.Reader")
+ }
+
+ var wh writeHook
+ brw.Writer.Reset(&wh)
+ brw.WriteByte(0)
+ brw.Flush()
+ if &c.writeBuf[0] != &wh.p[0] {
+ t.Error("connection did not reuse bufio.Writer")
+ }
+
+ brw = bufio.NewReadWriter(bufio.NewReaderSize(nil, 0), bufio.NewWriterSize(nil, 0))
+ c = newConnBRW(nil, false, 0, 0, brw)
+
+ if c.br == brw.Reader {
+ t.Error("connection used bufio.Reader with small size")
+ }
+
+ brw.Writer.Reset(&wh)
+ brw.WriteByte(0)
+ brw.Flush()
+ if &c.writeBuf[0] != &wh.p[0] {
+ t.Error("connection used bufio.Writer with small size")
+ }
+
+}