Permalink
Browse files

SDIFF fuzz test added.

  • Loading branch information...
1 parent 925090f commit 395d663d29e6c3fe8fe7c9a3503b96c9bde211f3 @antirez committed Nov 30, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 tests/unit/type/set.tcl
View
26 tests/unit/type/set.tcl
@@ -213,6 +213,32 @@ start_server {
r sdiff set1 set2 set3
} {}
+ test "SDIFF fuzzing" {
+ for {set j 0} {$j < 100} {incr j} {
+ unset -nocomplain s
+ array set s {}
+ set args {}
+ set num_sets [expr {[randomInt 10]+1}]
+ for {set i 0} {$i < $num_sets} {incr i} {
+ set num_elements [randomInt 100]
+ r del set_$i
+ lappend args set_$i
+ while {$num_elements} {
+ set ele [randomValue]
+ r sadd set_$i $ele
+ if {$i == 0} {
+ set s($ele) x
+ } else {
+ unset -nocomplain s($ele)
+ }
+ incr num_elements -1
+ }
+ }
+ set result [lsort [r sdiff {*}$args]]
+ assert_equal $result [lsort [array names s]]
+ }
+ }
+
test "SINTER against non-set should throw error" {
r set key1 x
assert_error "WRONGTYPE*" {r sinter key1 noset}

0 comments on commit 395d663

Please sign in to comment.