(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestEncodeArray(t *testing.T) { |
| 68 | resp := NewArray(nil) |
| 69 | testEncodeAndCheck(t, resp, []byte("*-1\r\n")) |
| 70 | resp.Array = []*Resp{} |
| 71 | testEncodeAndCheck(t, resp, []byte("*0\r\n")) |
| 72 | resp.Array = append(resp.Array, NewInt([]byte(strconv.Itoa(0)))) |
| 73 | testEncodeAndCheck(t, resp, []byte("*1\r\n:0\r\n")) |
| 74 | resp.Array = append(resp.Array, NewBulkBytes(nil)) |
| 75 | testEncodeAndCheck(t, resp, []byte("*2\r\n:0\r\n$-1\r\n")) |
| 76 | resp.Array = append(resp.Array, NewBulkBytes([]byte("test"))) |
| 77 | testEncodeAndCheck(t, resp, []byte("*3\r\n:0\r\n$-1\r\n$4\r\ntest\r\n")) |
| 78 | } |
| 79 | |
| 80 | func testEncodeAndCheck(t *testing.T, resp *Resp, expect []byte) { |
| 81 | b, err := EncodeToBytes(resp) |
nothing calls this directly
no test coverage detected