MCPcopy Index your code
hub / github.com/coder/websocket / TestHeader

Function TestHeader

frame_test.go:18–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestHeader(t *testing.T) {
19 t.Parallel()
20
21 t.Run("lengths", func(t *testing.T) {
22 t.Parallel()
23
24 lengths := []int{
25 124,
26 125,
27 126,
28 127,
29
30 65534,
31 65535,
32 65536,
33 65537,
34 }
35
36 for _, n := range lengths {
37 n := n
38 t.Run(strconv.Itoa(n), func(t *testing.T) {
39 t.Parallel()
40
41 testHeader(t, header{
42 payloadLength: int64(n),
43 })
44 })
45 }
46 })
47
48 t.Run("fuzz", func(t *testing.T) {
49 t.Parallel()
50
51 r := rand.New(rand.NewSource(time.Now().UnixNano()))
52 randBool := func() bool {
53 return r.Intn(2) == 0
54 }
55
56 for range 10000 {
57 h := header{
58 fin: randBool(),
59 rsv1: randBool(),
60 rsv2: randBool(),
61 rsv3: randBool(),
62 opcode: opcode(r.Intn(16)),
63
64 masked: randBool(),
65 payloadLength: r.Int63(),
66 }
67 if h.masked {
68 h.maskKey = r.Uint32()
69 }
70
71 testHeader(t, h)
72 }
73 })
74}
75

Callers

nothing calls this directly

Calls 2

testHeaderFunction · 0.85
opcodeTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…