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

Function TestJSON

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

Source from the content-addressed store, hash-verified

13)
14
15func TestJSON(t *testing.T) {
16 var buf bytes.Buffer
17 wc := newTestConn(nil, &buf, true)
18 rc := newTestConn(&buf, nil, false)
19
20 var actual, expect struct {
21 A int
22 B string
23 }
24 expect.A = 1
25 expect.B = "hello"
26
27 if err := wc.WriteJSON(&expect); err != nil {
28 t.Fatal("write", err)
29 }
30
31 if err := rc.ReadJSON(&actual); err != nil {
32 t.Fatal("read", err)
33 }
34
35 if !reflect.DeepEqual(&actual, &expect) {
36 t.Fatal("equal", actual, expect)
37 }
38}
39
40func TestPartialJSONRead(t *testing.T) {
41 var buf0, buf1 bytes.Buffer

Callers

nothing calls this directly

Calls 3

newTestConnFunction · 0.85
WriteJSONMethod · 0.80
ReadJSONMethod · 0.80

Tested by

no test coverage detected