MCPcopy Index your code
hub / github.com/CodisLabs/codis / TestEncodeArray

Function TestEncodeArray

pkg/proxy/redis/encoder_test.go:67–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func 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
80func testEncodeAndCheck(t *testing.T, resp *Resp, expect []byte) {
81 b, err := EncodeToBytes(resp)

Callers

nothing calls this directly

Calls 4

NewArrayFunction · 0.85
testEncodeAndCheckFunction · 0.85
NewIntFunction · 0.85
NewBulkBytesFunction · 0.85

Tested by

no test coverage detected