mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
still more tests
This commit is contained in:
parent
5384a2d82e
commit
98e1bb8136
@ -877,18 +877,23 @@ proc main {server port} {
|
|||||||
lsort [array names myset]
|
lsort [array names myset]
|
||||||
} {a b c}
|
} {a b c}
|
||||||
|
|
||||||
test {Create a random list} {
|
test {Create a random list and a random set} {
|
||||||
set tosort {}
|
set tosort {}
|
||||||
array set seenrand {}
|
array set seenrand {}
|
||||||
for {set i 0} {$i < 10000} {incr i} {
|
for {set i 0} {$i < 10000} {incr i} {
|
||||||
while 1 {
|
while 1 {
|
||||||
# Make sure all the weights are different because
|
# Make sure all the weights are different because
|
||||||
# Redis does not use a stable sort but Tcl does.
|
# Redis does not use a stable sort but Tcl does.
|
||||||
|
randpath {
|
||||||
set rint [expr int(rand()*1000000)]
|
set rint [expr int(rand()*1000000)]
|
||||||
|
} {
|
||||||
|
set rint [expr rand()]
|
||||||
|
}
|
||||||
if {![info exists seenrand($rint)]} break
|
if {![info exists seenrand($rint)]} break
|
||||||
}
|
}
|
||||||
set seenrand($rint) x
|
set seenrand($rint) x
|
||||||
$r lpush tosort $i
|
$r lpush tosort $i
|
||||||
|
$r sadd tosort-set $i
|
||||||
$r set weight_$i $rint
|
$r set weight_$i $rint
|
||||||
lappend tosort [list $i $rint]
|
lappend tosort [list $i $rint]
|
||||||
}
|
}
|
||||||
@ -904,6 +909,10 @@ proc main {server port} {
|
|||||||
$r sort tosort {BY weight_*}
|
$r sort tosort {BY weight_*}
|
||||||
} $res
|
} $res
|
||||||
|
|
||||||
|
test {the same SORT with BY, but against the newly created set} {
|
||||||
|
$r sort tosort-set {BY weight_*}
|
||||||
|
} $res
|
||||||
|
|
||||||
test {SORT with BY and STORE against the newly created list} {
|
test {SORT with BY and STORE against the newly created list} {
|
||||||
$r sort tosort {BY weight_*} store sort-res
|
$r sort tosort {BY weight_*} store sort-res
|
||||||
$r lrange sort-res 0 -1
|
$r lrange sort-res 0 -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user