MCPcopy
hub / github.com/gorilla/websocket / TestTruncWriter

Function TestTruncWriter

compression_test.go:15–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13func (nopCloser) Close() error { return nil }
14
15func TestTruncWriter(t *testing.T) {
16 const data = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijlkmnopqrstuvwxyz987654321"
17 for n := 1; n <= 10; n++ {
18 var b bytes.Buffer
19 w := &truncWriter{w: nopCloser{&b}}
20 p := []byte(data)
21 for len(p) > 0 {
22 m := len(p)
23 if m > n {
24 m = n
25 }
26 w.Write(p[:m])
27 p = p[m:]
28 }
29 if b.String() != data[:len(data)-len(w.p)] {
30 t.Errorf("%d: %q", n, b.String())
31 }
32 }
33}
34
35func textMessages(num int) [][]byte {
36 messages := make([][]byte, num)

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.95
StringMethod · 0.80

Tested by

no test coverage detected