Test ZRANGE and ZREVRANGE
(t *testing.T)
| 302 | |
| 303 | // Test ZRANGE and ZREVRANGE |
| 304 | func 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 | ) |
nothing calls this directly
no test coverage detected