From: antirez Date: Sun, 29 Nov 2009 09:29:08 +0000 (+0100) Subject: more tests in test-redis.tcl, some minor fix X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/0b13687c25eda63a06296215f2da950f567801be?ds=inline more tests in test-redis.tcl, some minor fix --- diff --git a/TODO b/TODO index a62743ea..64fa91af 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 65571f32..81a8ee2d 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 039941d3..bf89d823 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