@@ -28,7 +28,15 @@ test(async function beforeAll() {
28
28
"del1" ,
29
29
"del2" ,
30
30
"spop" ,
31
- "spopWithCount"
31
+ "spopWithCount" ,
32
+ "zrange" ,
33
+ "zrangeWithScores" ,
34
+ "zrevrange" ,
35
+ "zrevrangeWithScores" ,
36
+ "zrangebyscore" ,
37
+ "zrangebyscoreWithScores" ,
38
+ "zrevrangebyscore" ,
39
+ "zrevrangebyscoreWithScores"
32
40
) ;
33
41
} ) ;
34
42
@@ -112,6 +120,74 @@ test(async function testSpopWithCount() {
112
120
assertArrayContains ( v , [ "a" , "b" ] ) ;
113
121
} ) ;
114
122
123
+ test ( async function testZrange ( ) {
124
+ redis . zadd ( "zrange" , 1 , "one" ) ;
125
+ redis . zadd ( "zrange" , 2 , "two" ) ;
126
+ redis . zadd ( "zrange" , 3 , "three" ) ;
127
+ const v = await redis . zrange ( "zrange" , 0 , 1 ) ;
128
+ assertEquals ( v , [ "one" , "two" ] ) ;
129
+ } ) ;
130
+
131
+ test ( async function testZrangeWithScores ( ) {
132
+ redis . zadd ( "zrangeWithScores" , 1 , "one" ) ;
133
+ redis . zadd ( "zrangeWithScores" , 2 , "two" ) ;
134
+ redis . zadd ( "zrangeWithScores" , 3 , "three" ) ;
135
+ const v = await redis . zrange ( "zrangeWithScores" , 0 , 1 , { withScore : true } ) ;
136
+ assertEquals ( v , [ "one" , "1" , "two" , "2" ] ) ;
137
+ } ) ;
138
+
139
+ test ( async function testZrevrange ( ) {
140
+ redis . zadd ( "zrevrange" , 1 , "one" ) ;
141
+ redis . zadd ( "zrevrange" , 2 , "two" ) ;
142
+ redis . zadd ( "zrevrange" , 3 , "three" ) ;
143
+ const v = await redis . zrevrange ( "zrevrange" , 0 , 1 )
144
+ assertEquals ( v , [ "three" , "two" ] ) ;
145
+ } ) ;
146
+
147
+ test ( async function testZrevrangeWithScores ( ) {
148
+ redis . zadd ( "zrevrangeWithScores" , 1 , "one" ) ;
149
+ redis . zadd ( "zrevrangeWithScores" , 2 , "two" ) ;
150
+ redis . zadd ( "zrevrangeWithScores" , 3 , "three" ) ;
151
+ const v = await redis . zrevrange ( "zrevrangeWithScores" , 0 , 1 , { withScore : true } ) ;
152
+ assertEquals ( v , [ "three" , "3" , "two" , "2" ] ) ;
153
+ } ) ;
154
+
155
+ test ( async function testZrangebyscore ( ) {
156
+ redis . zadd ( "zrangebyscore" , 2 , "m1" ) ;
157
+ redis . zadd ( "zrangebyscore" , 5 , "m2" ) ;
158
+ redis . zadd ( "zrangebyscore" , 8 , "m3" ) ;
159
+ redis . zadd ( "zrangebyscore" , 10 , "m4" ) ;
160
+ const v = await redis . zrangebyscore ( "zrangebyscore" , 3 , 9 ) ;
161
+ assertEquals ( v , [ "m2" , "m3" ] ) ;
162
+ } ) ;
163
+
164
+ test ( async function testZrangebyscoreWithScores ( ) {
165
+ redis . zadd ( "zrangebyscoreWithScores" , 2 , "m1" ) ;
166
+ redis . zadd ( "zrangebyscoreWithScores" , 5 , "m2" ) ;
167
+ redis . zadd ( "zrangebyscoreWithScores" , 8 , "m3" ) ;
168
+ redis . zadd ( "zrangebyscoreWithScores" , 10 , "m4" ) ;
169
+ const v = await redis . zrangebyscore ( "zrangebyscoreWithScores" , 3 , 9 , { withScore : true } ) ;
170
+ assertEquals ( v , [ "m2" , "5" , "m3" , "8" ] ) ;
171
+ } ) ;
172
+
173
+ test ( async function testZrevrangebyscore ( ) {
174
+ redis . zadd ( "zrevrangebyscore" , 2 , "m1" ) ;
175
+ redis . zadd ( "zrevrangebyscore" , 5 , "m2" ) ;
176
+ redis . zadd ( "zrevrangebyscore" , 8 , "m3" ) ;
177
+ redis . zadd ( "zrevrangebyscore" , 10 , "m4" ) ;
178
+ const v = await redis . zrevrangebyscore ( "zrevrangebyscore" , 9 , 4 ) ;
179
+ assertEquals ( v , [ "m3" , "m2" ] ) ;
180
+ } ) ;
181
+
182
+ test ( async function testZrevrangebyscore ( ) {
183
+ redis . zadd ( "zrevrangebyscoreWithScores" , 2 , "m1" ) ;
184
+ redis . zadd ( "zrevrangebyscoreWithScores" , 5 , "m2" ) ;
185
+ redis . zadd ( "zrevrangebyscoreWithScores" , 8 , "m3" ) ;
186
+ redis . zadd ( "zrevrangebyscoreWithScores" , 10 , "m4" ) ;
187
+ const v = await redis . zrevrangebyscore ( "zrevrangebyscoreWithScores" , 9 , 4 , { withScore : true } ) ;
188
+ assertEquals ( v , [ "m3" , "8" , "m2" , "5" ] ) ;
189
+ } ) ;
190
+
115
191
test ( async function testConcurrent ( ) {
116
192
let promises : Promise < any > [ ] = [ ] ;
117
193
for ( const key of [ "a" , "b" , "c" ] ) {
0 commit comments