MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / TestSortedSetRange

Function TestSortedSetRange

IceFireDB-Redis-Proxy/test/cmd_sorted_set_test.go:304–425  ·  view source on GitHub ↗

Test ZRANGE and ZREVRANGE

(t *testing.T)

Source from the content-addressed store, hash-verified

302
303// Test ZRANGE and ZREVRANGE
304func TestSortedSetRange(t *testing.T) {
305 // ZREVRANGE is the same code as ZRANGE
306 server.Clear()
307 c, err := proto.Dial(server.Addr())
308 ok(t, err)
309 defer c.Close()
310 s := server.Direct()
311
312 s.ZAdd("z", 1, "one")
313 s.ZAdd("z", 2, "two")
314 s.ZAdd("z", 2, "zwei")
315 s.ZAdd("z", 3, "three")
316 s.ZAdd("z", 3, "drei")
317 s.ZAdd("z", math.Inf(+1), "inf")
318
319 {
320 mustDo(t, c,
321 "ZRANGE", "z", "0", "-1",
322 proto.Strings("one", "two", "zwei", "drei", "three", "inf"),
323 )
324
325 mustDo(t, c,
326 "ZREVRANGE", "z", "0", "-1",
327 proto.Strings("inf", "three", "drei", "zwei", "two", "one"),
328 )
329 }
330 {
331 mustDo(t, c,
332 "ZRANGE", "z", "0", "1",
333 proto.Strings("one", "two"),
334 )
335
336 mustDo(t, c,
337 "ZREVRANGE", "z", "0", "1",
338 proto.Strings("inf", "three"),
339 )
340 }
341 {
342 mustDo(t, c,
343 "ZRANGE", "z", "-1", "-1",
344 proto.Strings("inf"),
345 )
346
347 mustDo(t, c,
348 "ZREVRANGE", "z", "-1", "-1",
349 proto.Strings("one"),
350 )
351 }
352
353 // weird cases.
354 mustDo(t, c,
355 "ZRANGE", "z", "-100", "-100",
356 proto.Strings(),
357 )
358 mustDo(t, c,
359 "ZRANGE", "z", "100", "400",
360 proto.Strings(),
361 )

Callers

nothing calls this directly

Calls 12

ClearFunction · 0.92
DialFunction · 0.92
AddrFunction · 0.92
DirectFunction · 0.92
StringsFunction · 0.92
ErrorFunction · 0.92
SetMethod · 0.80
okFunction · 0.70
mustDoFunction · 0.70
errWrongNumberFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected