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
616bca99
Commit
616bca99
authored
Feb 11, 2015
by
antirez
Browse files
SPOP explicit tests for the three different code paths.
parent
dc10245f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/type/set.tcl
View file @
616bca99
...
...
@@ -346,6 +346,33 @@ start_server {
r spop nonexisting_key 100
}
{}
test
"SPOP new implementation: code path #1"
{
set content
{
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
}
create_set myset $content
set res
[
r spop myset 30
]
assert
{[
lsort $content
]
eq
[
lsort $res
]}
}
test
"SPOP new implementation: code path #2"
{
set content
{
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
}
create_set myset $content
set res
[
r spop myset 2
]
assert
{[
llength $res
]
== 2
}
assert
{[
r scard myset
]
== 18
}
set union
[
concat
[
r smembers myset
]
$res
]
assert
{[
lsort $union
]
eq
[
lsort $content
]}
}
test
"SPOP new implementation: code path #3"
{
set content
{
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
}
create_set myset $content
set res
[
r spop myset 18
]
assert
{[
llength $res
]
== 18
}
assert
{[
r scard myset
]
== 2
}
set union
[
concat
[
r smembers myset
]
$res
]
assert
{[
lsort $union
]
eq
[
lsort $content
]}
}
test
"SRANDMEMBER with <count> against non existing key"
{
r srandmember nonexisting_key 100
}
{}
...
...
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