From 0b13687c25eda63a06296215f2da950f567801be Mon Sep 17 00:00:00 2001 From: antirez Date: Sun, 29 Nov 2009 10:29:08 +0100 Subject: [PATCH] more tests in test-redis.tcl, some minor fix --- TODO | 2 -- redis.c | 3 ++- test-redis.tcl | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a62743ea2..64fa91afc 100644 --- a/TODO +++ b/TODO @@ -7,8 +7,6 @@ Most of the features already implemented for this release. The following is a li * Man pages for SRANDMEMBER, missing Z-commands, ... * Write docs for the "STORE" operaiton of SORT. Link to the article about SORT by written by defunkt. -* ZRANGEBYSCORE LIMIT option and test. -* check the command table for deny on OOM correctness. VERSION 1.4 TODO (Hash type) ============================ diff --git a/redis.c b/redis.c index 65571f328..81a8ee2dc 100644 --- a/redis.c +++ b/redis.c @@ -501,7 +501,7 @@ static struct redisCommand cmdTable[] = { {"lrange",lrangeCommand,4,REDIS_CMD_INLINE}, {"ltrim",ltrimCommand,4,REDIS_CMD_INLINE}, {"lrem",lremCommand,4,REDIS_CMD_BULK}, - {"rpoplpush",rpoplpushcommand,3,REDIS_CMD_BULK}, + {"rpoplpush",rpoplpushcommand,3,REDIS_CMD_BULK|REDIS_CMD_DENYOOM}, {"sadd",saddCommand,3,REDIS_CMD_BULK|REDIS_CMD_DENYOOM}, {"srem",sremCommand,3,REDIS_CMD_BULK}, {"smove",smoveCommand,4,REDIS_CMD_BULK}, @@ -4570,6 +4570,7 @@ static void zrangebyscoreCommand(redisClient *c) { } else if (c->argc == 7) { offset = atoi(c->argv[5]->ptr); limit = atoi(c->argv[6]->ptr); + if (offset < 0) offset = 0; } o = lookupKeyRead(c->db,c->argv[1]); diff --git a/test-redis.tcl b/test-redis.tcl index 039941d3a..bf89d823b 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -1063,6 +1063,30 @@ proc main {server port} { set _ $err } {} + test {ZRANGEBYSCORE with LIMIT} { + $r del zset + $r zadd zset 1 a + $r zadd zset 2 b + $r zadd zset 3 c + $r zadd zset 4 d + $r zadd zset 5 e + list \ + [$r zrangebyscore zset 0 10 LIMIT 0 2] \ + [$r zrangebyscore zset 0 10 LIMIT 2 3] \ + [$r zrangebyscore zset 0 10 LIMIT 2 10] \ + [$r zrangebyscore zset 0 10 LIMIT 20 10] + } {{a b} {c d e} {c d e} {}} + + test {SORT against sorted sets} { + $r del zset + $r zadd zset 1 a + $r zadd zset 5 b + $r zadd zset 2 c + $r zadd zset 10 d + $r zadd zset 3 e + $r sort zset alpha desc + } {e d c b a} + test {Sorted sets +inf and -inf handling} { $r del zset $r zadd zset -100 a