Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ZSets double to string serialization fixed

  • Loading branch information...
commit eaa256ad256e385f6f448df6c162ff14f4d2956b 1 parent 9155ea9
@antirez authored
Showing with 22 additions and 6 deletions.
  1. +3 −0  .gitignore
  2. +2 −2 TODO
  3. +2 −2 redis.c
  4. +15 −2 test-redis.tcl
View
3  .gitignore
@@ -1,5 +1,7 @@
+00-RELEASENOTES
*.o
*.rdb
+*.log
redis-cli
redis-server
redis-benchmark
@@ -7,3 +9,4 @@ doc-tools
mkrelease.sh
release
myredis.conf
+misc/*
View
4 TODO
@@ -6,8 +6,8 @@ VERSION 1.1 TODO
* Add all the missing symbols for the static functions into the table. Crete a Tcl script to check this. This backtrace on segfault is indeed *very* useful.
* Use strcoll() to compare objects in sorted sets, like it already happens for SORT.
* LMOVE, as discussed in the Redis group.
-* EXPIRE and EXPIREAT tests.
-* Write docs for the "STORE" operaiton of SORT.
+* EXPIRE, EXPIREAT, ZSCORE tests.
+* Write docs for the "STORE" operaiton of SORT, and GET "#" option.
* Append only mode: testing and a command to rebuild the log from scratch.
VERSION 1.2 TODO
View
4 redis.c
@@ -2331,7 +2331,7 @@ static int rdbSaveDoubleValue(FILE *fp, double val) {
len = 1;
buf[0] = (val < 0) ? 255 : 254;
} else {
- snprintf((char*)buf+1,sizeof(buf)-1,"%.16g",val);
+ snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val);
buf[0] = strlen((char*)buf);
len = buf[0]+1;
}
@@ -4307,7 +4307,7 @@ static void zscoreCommand(redisClient *c) {
char buf[128];
double *score = dictGetEntryVal(de);
- snprintf(buf,sizeof(buf),"%.16g",*score);
+ snprintf(buf,sizeof(buf),"%.17g",*score);
addReplySds(c,sdscatprintf(sdsempty(),"$%d\r\n%s\r\n",
strlen(buf),buf));
}
View
17 test-redis.tcl
@@ -789,8 +789,21 @@ proc main {server port} {
} {{x y z} {y x z}}
test {ZSCORE} {
- list [$r zscore ztmp x] [$r zscore ztmp y] [$r zscore ztmp z]
- } {10 1 30}
+ set aux {}
+ set err {}
+ for {set i 0} {$i < 1000} {incr i} {
+ set score [expr rand()]
+ lappend aux $score
+ $r zadd zscoretest $score $i
+ }
+ for {set i 0} {$i < 1000} {incr i} {
+ if {[$r zscore zscoretest $i] != [lindex $aux $i]} {
+ set err "Expected score was [lindex $aux $i] but got [$r zscore zscoretest $i] for element $i"
+ break
+ }
+ }
+ set _ $err
+ } {}
test {ZRANGE and ZREVRANGE} {
list [$r zrange ztmp 0 -1] [$r zrevrange ztmp 0 -1]
Please sign in to comment.
Something went wrong with that request. Please try again.