more tests in test-redis.tcl, some minor fix

This commit is contained in:
antirez 2009-11-29 10:29:08 +01:00
parent a5eb649bfa
commit 0b13687c25
3 changed files with 26 additions and 3 deletions

2
TODO
View File

@ -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, ... * 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. * 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) VERSION 1.4 TODO (Hash type)
============================ ============================

View File

@ -501,7 +501,7 @@ static struct redisCommand cmdTable[] = {
{"lrange",lrangeCommand,4,REDIS_CMD_INLINE}, {"lrange",lrangeCommand,4,REDIS_CMD_INLINE},
{"ltrim",ltrimCommand,4,REDIS_CMD_INLINE}, {"ltrim",ltrimCommand,4,REDIS_CMD_INLINE},
{"lrem",lremCommand,4,REDIS_CMD_BULK}, {"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}, {"sadd",saddCommand,3,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
{"srem",sremCommand,3,REDIS_CMD_BULK}, {"srem",sremCommand,3,REDIS_CMD_BULK},
{"smove",smoveCommand,4,REDIS_CMD_BULK}, {"smove",smoveCommand,4,REDIS_CMD_BULK},
@ -4570,6 +4570,7 @@ static void zrangebyscoreCommand(redisClient *c) {
} else if (c->argc == 7) { } else if (c->argc == 7) {
offset = atoi(c->argv[5]->ptr); offset = atoi(c->argv[5]->ptr);
limit = atoi(c->argv[6]->ptr); limit = atoi(c->argv[6]->ptr);
if (offset < 0) offset = 0;
} }
o = lookupKeyRead(c->db,c->argv[1]); o = lookupKeyRead(c->db,c->argv[1]);

View File

@ -1063,6 +1063,30 @@ proc main {server port} {
set _ $err 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} { test {Sorted sets +inf and -inf handling} {
$r del zset $r del zset
$r zadd zset -100 a $r zadd zset -100 a