for {set j 0} {$j < $ops} {incr j} {
set k [randomKey]
set v [randomValue]
- set d [expr {rand()}]
+ randpath {
+ set d [expr {rand()}]
+ } {
+ set d [expr {rand()}]
+ } {
+ set d [expr {rand()}]
+ } {
+ set d [expr {rand()}]
+ } {
+ set d [expr {rand()}]
+ } {
+ randpath {set d +inf} {set d -inf}
+ }
set t [$r type $k]
if {$t eq {none}} {
$r incrby novar 17179869184
} {34359738368}
+ test {INCR against key with spaces (no integer encoded)} {
+ $r set novar " 11 "
+ $r incr novar
+ } {12}
+
test {DECRBY over 32bit value with over 32bit increment, negative res} {
$r set novar 17179869184
$r decrby novar 17179869185
append res [$r lindex mylist 0]
append res [$r lindex mylist 1]
append res [$r lindex mylist 2]
- } {3bac}
+ list $res [$r lindex mylist 100]
+ } {3bac {}}
test {DEL a list} {
$r del mylist
format $err
} {ERR*}
+ test {LLEN against non existing key} {
+ $r llen not-a-key
+ } {0}
+
test {LINDEX against non-list value error} {
catch {$r lindex mylist 0} err
format $err
} {ERR*}
+ test {LINDEX against non existing key} {
+ $r lindex not-a-key 10
+ } {}
+
test {LPUSH against non-list value error} {
catch {$r lpush mylist 0} err
format $err
list [$r lrange mylist 0 -1] [$r type newlist] [string range $err 0 2]
} {{a b c d} string ERR}
+ test {RPOPLPUSH against non existing src key} {
+ $r del mylist
+ $r del newlist
+ $r rpoplpush mylist newlist
+ } {}
+
test {RENAME basic usage} {
$r set mykey hello
$r rename mykey mykey1
$r lrange mylist 0 -1
} {99 98 97 96 95}
+ test {LTRIM stress testing} {
+ set mylist {}
+ set err {}
+ for {set i 0} {$i < 20} {incr i} {
+ lappend mylist $i
+ }
+
+ for {set j 0} {$j < 100} {incr j} {
+ # Fill the list
+ $r del mylist
+ for {set i 0} {$i < 20} {incr i} {
+ $r rpush mylist $i
+ }
+ # Trim at random
+ set a [randomInt 20]
+ set b [randomInt 20]
+ $r ltrim mylist $a $b
+ if {[$r lrange mylist 0 -1] ne [lrange $mylist $a $b]} {
+ set err "[$r lrange mylist 0 -1] != [lrange $mylist $a $b]"
+ break
+ }
+ }
+ set _ $err
+ } {}
+
test {LSET} {
+ $r del mylist
+ foreach x {99 98 97 96 95} {
+ $r rpush mylist $x
+ }
$r lset mylist 1 foo
$r lset mylist -1 bar
$r lrange mylist 0 -1
set _ $err
} {}
- test {ZRANGE and ZREVRANGE} {
- list [$r zrange ztmp 0 -1] [$r zrevrange ztmp 0 -1]
- } {{y x z} {z x y}}
+ test {ZRANGE and ZREVRANGE basics} {
+ list [$r zrange ztmp 0 -1] [$r zrevrange ztmp 0 -1] \
+ [$r zrange ztmp 1 -1] [$r zrevrange ztmp 1 -1]
+ } {{y x z} {z x y} {x z} {x y}}
test {ZSETs stress tester - sorting is working well?} {
set delta 0