Skip to content

Commit

Permalink
wsflate: helper test
Browse files Browse the repository at this point in the history
  • Loading branch information
gobwas committed Feb 6, 2021
1 parent 604cf2e commit d79a089
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions wsflate/helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package wsflate

import (
"bytes"
"testing"

"github.com/gobwas/ws"
)

func TestHelperWriteAndRead(t *testing.T) {
const text = "hello, wsflate!"
f := ws.NewTextFrame([]byte(text))
c, err := CompressFrame(f)
if err != nil {
t.Fatalf("can't compress frame: %v", err)
}
d, err := DecompressFrame(c)
if err != nil {
t.Fatalf("can't decompress frame: %v", err)
}
if f.Header != d.Header {
t.Fatalf("original and decompressed headers are not equal")
}
if !bytes.Equal(f.Payload, d.Payload) {
t.Fatalf("original and decompressed payload are not equal")
}
}

0 comments on commit d79a089

Please sign in to comment.