1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Better ZRange API.

This commit is contained in:
Vladimir Mihailenco
2013-10-15 11:18:16 +03:00
parent 6485188460
commit 8fd6b4ad9f
2 changed files with 52 additions and 28 deletions

View File

@ -2016,19 +2016,31 @@ func (t *RedisTest) TestZRangeByScore(c *C) {
zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
c.Assert(zAdd.Err(), IsNil)
zRangeByScore := t.client.ZRangeByScore("zset", "-inf", "+inf", 0, 0)
zRangeByScore := t.client.ZRangeByScore("zset", redis.ZRangeByScore{
Min: "-inf",
Max: "+inf",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, []string{"one", "two", "three"})
zRangeByScore = t.client.ZRangeByScore("zset", "1", "2", 0, 0)
zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
Min: "1",
Max: "2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, []string{"one", "two"})
zRangeByScore = t.client.ZRangeByScore("zset", "(1", "2", 0, 0)
zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
Min: "(1",
Max: "2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, []string{"two"})
zRangeByScore = t.client.ZRangeByScore("zset", "(1", "(2", 0, 0)
zRangeByScore = t.client.ZRangeByScore("zset", redis.ZRangeByScore{
Min: "(1",
Max: "(2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, []string{})
}
@ -2041,19 +2053,31 @@ func (t *RedisTest) TestZRangeByScoreWithScoresMap(c *C) {
zAdd = t.client.ZAdd("zset", redis.Z{3, "three"})
c.Assert(zAdd.Err(), IsNil)
zRangeByScore := t.client.ZRangeByScoreWithScoresMap("zset", "-inf", "+inf", 0, 0)
zRangeByScore := t.client.ZRangeByScoreWithScoresMap("zset", redis.ZRangeByScore{
Min: "-inf",
Max: "+inf",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, map[string]float64{"one": 1, "two": 2, "three": 3})
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", "1", "2", 0, 0)
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", redis.ZRangeByScore{
Min: "1",
Max: "2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, map[string]float64{"one": 1, "two": 2})
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", "(1", "2", 0, 0)
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", redis.ZRangeByScore{
Min: "(1",
Max: "2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, map[string]float64{"two": 2})
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", "(1", "(2", 0, 0)
zRangeByScore = t.client.ZRangeByScoreWithScoresMap("zset", redis.ZRangeByScore{
Min: "(1",
Max: "(2",
})
c.Assert(zRangeByScore.Err(), IsNil)
c.Assert(zRangeByScore.Val(), DeepEquals, map[string]float64{})
}