(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func 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 | |
| 40 | func TestPartialJSONRead(t *testing.T) { |
| 41 | var buf0, buf1 bytes.Buffer |
nothing calls this directly
no test coverage detected