mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Test: added SSCAN test.
This commit is contained in:
parent
5fdb94fd98
commit
ddc80e026f
@ -52,4 +52,38 @@ start_server {tags {"scan"}} {
|
||||
set keys [lsort -unique $keys]
|
||||
assert_equal 100 [llength $keys]
|
||||
}
|
||||
|
||||
foreach enc {intset hashtable} {
|
||||
test "SSCAN with encoding $enc" {
|
||||
# Create the Set
|
||||
r del set
|
||||
if {$enc eq {intset}} {
|
||||
set prefix ""
|
||||
} else {
|
||||
set prefix "ele:"
|
||||
}
|
||||
set elements {}
|
||||
for {set j 0} {$j < 100} {incr j} {
|
||||
lappend elements ${prefix}${j}
|
||||
}
|
||||
r sadd set {*}$elements
|
||||
|
||||
# Verify that the encoding matches.
|
||||
assert {[r object encoding set] eq $enc}
|
||||
|
||||
# Test SSCAN
|
||||
set cur 0
|
||||
set keys {}
|
||||
while 1 {
|
||||
set res [r sscan set $cur]
|
||||
set cur [lindex $res 0]
|
||||
set k [lindex $res 1]
|
||||
lappend keys {*}$k
|
||||
if {$cur == 0} break
|
||||
}
|
||||
|
||||
set keys [lsort -unique $keys]
|
||||
assert_equal 100 [llength $keys]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user