mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
SPOP explicit tests for the three different code paths.
This commit is contained in:
parent
a37d0f8b48
commit
dffbbb5a78
@ -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
|
||||
} {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user