Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ab6f4195
Commit
ab6f4195
authored
Oct 30, 2013
by
antirez
Browse files
Test: added ZSCAN test.
parent
13e879c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/scan.tcl
View file @
ab6f4195
...
...
@@ -126,4 +126,44 @@ start_server {tags {"scan"}} {
assert_equal $count
[
llength $keys2
]
}
}
foreach enc
{
ziplist skiplist
}
{
test
"ZSCAN with encoding
$enc
"
{
# Create the Sorted Set
r del zset
if
{
$enc
eq
{
ziplist
}}
{
set count 30
}
else
{
set count 1000
}
set elements
{}
for
{
set j 0
}
{
$j
< $count
}
{
incr j
}
{
lappend elements $j key:$j
}
r zadd zset
{*}
$elements
# Verify that the encoding matches.
assert
{[
r object encoding zset
]
eq $enc
}
# Test ZSCAN
set cur 0
set keys
{}
while 1
{
set res
[
r zscan zset $cur
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
set keys2
{}
foreach
{
k v
}
$keys
{
assert
{
$k
eq
"key:
$v
"
}
lappend keys2 $k
}
set keys2
[
lsort -unique $keys2
]
assert_equal $count
[
llength $keys2
]
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment