From 395d663d29e6c3fe8fe7c9a3503b96c9bde211f3 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 30 Nov 2012 01:35:34 +0100 Subject: [PATCH] SDIFF fuzz test added. --- tests/unit/type/set.tcl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/type/set.tcl b/tests/unit/type/set.tcl index b5d44ea9..9603eb56 100644 --- a/tests/unit/type/set.tcl +++ b/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} -- 2.45.2