@@ -27,37 +27,45 @@ func testListLrangePosIdx(stageHarness *test_case_harness.TestCaseHarness) error
2727 defer client .Close ()
2828
2929 randomListKey := testerutils_random .RandomWord ()
30- listSize := testerutils_random .RandomInt (4 , 5 )
30+ listSize := testerutils_random .RandomInt (4 , 6 )
3131 randomList := testerutils_random .RandomWords (listSize )
3232 middleIndex := testerutils_random .RandomInt (1 , listSize - 1 )
3333 missingKey := fmt .Sprintf ("missing_key_%d" , testerutils_random .RandomInt (1 , 100 ))
3434
3535 multiCommandTestCase := test_cases.MultiCommandTestCase {
36- Commands : [][]string {
37- append ([]string {"RPUSH" , randomListKey }, randomList ... ),
38-
36+ CommandWithAssertions : []test_cases.CommandWithAssertion {
37+ {
38+ Command : append ([]string {"RPUSH" , randomListKey }, randomList ... ),
39+ Assertion : resp_assertions .NewIntegerAssertion (listSize ),
40+ },
3941 // usual test cases
40- {"LRANGE" , randomListKey , "0" , strconv .Itoa (middleIndex )},
41- {"LRANGE" , randomListKey , strconv .Itoa (middleIndex ), strconv .Itoa (listSize - 1 )},
42- {"LRANGE" , randomListKey , "0" , strconv .Itoa (listSize - 1 )},
43-
42+ {
43+ Command : []string {"LRANGE" , randomListKey , "0" , strconv .Itoa (middleIndex )},
44+ Assertion : resp_assertions .NewOrderedStringArrayAssertion (randomList [0 : middleIndex + 1 ]),
45+ },
46+ {
47+ Command : []string {"LRANGE" , randomListKey , strconv .Itoa (middleIndex ), strconv .Itoa (listSize - 1 )},
48+ Assertion : resp_assertions .NewOrderedStringArrayAssertion (randomList [middleIndex :listSize ]),
49+ },
50+ {
51+ Command : []string {"LRANGE" , randomListKey , "0" , strconv .Itoa (listSize - 1 )},
52+ Assertion : resp_assertions .NewOrderedStringArrayAssertion (randomList [0 :listSize ]),
53+ },
4454 // start index > end index
45- {"LRANGE" , randomListKey , "1" , "0" },
46-
55+ {
56+ Command : []string {"LRANGE" , randomListKey , "1" , "0" },
57+ Assertion : resp_assertions .NewOrderedStringArrayAssertion ([]string {}),
58+ },
4759 // end index out of bounds
48- {"LRANGE" , randomListKey , "0" , strconv .Itoa (listSize * 2 )},
49-
60+ {
61+ Command : []string {"LRANGE" , randomListKey , "0" , strconv .Itoa (listSize * 2 )},
62+ Assertion : resp_assertions .NewOrderedStringArrayAssertion (randomList [0 :listSize ]),
63+ },
5064 // key doesn't exist
51- {"LRANGE" , missingKey , "0" , "1" },
52- },
53- Assertions : []resp_assertions.RESPAssertion {
54- resp_assertions .NewIntegerAssertion (listSize ),
55- resp_assertions .NewOrderedStringArrayAssertion (randomList [0 : middleIndex + 1 ]),
56- resp_assertions .NewOrderedStringArrayAssertion (randomList [middleIndex :listSize ]),
57- resp_assertions .NewOrderedStringArrayAssertion (randomList [0 :listSize ]),
58- resp_assertions .NewOrderedStringArrayAssertion ([]string {}),
59- resp_assertions .NewOrderedStringArrayAssertion (randomList [0 :listSize ]),
60- resp_assertions .NewOrderedStringArrayAssertion ([]string {}),
65+ {
66+ Command : []string {"LRANGE" , missingKey , "0" , "1" },
67+ Assertion : resp_assertions .NewOrderedStringArrayAssertion ([]string {}),
68+ },
6169 },
6270 }
6371
0 commit comments