summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-02-11 10:12:00 +0100
committerantirez <antirez@gmail.com>2015-02-11 10:52:28 +0100
commitdffbbb5a78154d42395284e9b8bf33b236a45599 (patch)
tree09892d10b4ee979f48c55d561a0a0062992c7bef
parenta37d0f8b48e91d1ec50ac97ef7fa832794cf6edd (diff)
downloadredis-dffbbb5a78154d42395284e9b8bf33b236a45599.tar.gz
SPOP explicit tests for the three different code paths.
-rw-r--r--tests/unit/type/set.tcl27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl
index 74a8fb318..a9a3d0835 100644
--- a/tests/unit/type/set.tcl
+++ b/tests/unit/type/set.tcl
@@ -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
} {}