"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/type/set.tcl" between
redis-6.2.4.tar.gz and redis-6.2.5.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

set.tcl  (redis-6.2.4):set.tcl  (redis-6.2.5)
skipping to change at line 279 skipping to change at line 279
unset -nocomplain s($ele) unset -nocomplain s($ele)
} }
incr num_elements -1 incr num_elements -1
} }
} }
set result [lsort [r sdiff {*}$args]] set result [lsort [r sdiff {*}$args]]
assert_equal $result [lsort [array names s]] assert_equal $result [lsort [array names s]]
} }
} }
test "SINTER against non-set should throw error" { test "SDIFF against non-set should throw error" {
r set key1 x # with an empty set
assert_error "WRONGTYPE*" {r sinter key1 noset} r set key1{t} x
assert_error "WRONGTYPE*" {r sdiff key1{t} noset{t}}
# different order
assert_error "WRONGTYPE*" {r sdiff noset{t} key1{t}}
# with a legal set
r del set1{t}
r sadd set1{t} a b c
assert_error "WRONGTYPE*" {r sdiff key1{t} set1{t}}
# different order
assert_error "WRONGTYPE*" {r sdiff set1{t} key1{t}}
}
test "SDIFF should handle non existing key as empty" {
r del set1{t} set2{t} set3{t}
r sadd set1{t} a b c
r sadd set2{t} b c d
assert_equal {a} [lsort [r sdiff set1{t} set2{t} set3{t}]]
assert_equal {} [lsort [r sdiff set3{t} set2{t} set1{t}]]
}
test "SDIFFSTORE against non-set should throw error" {
r del set1{t} set2{t} set3{t} key1{t}
r set key1{t} x
# with en empty dstkey
assert_error "WRONGTYPE*" {r SDIFFSTORE set3{t} key1{t} noset{t}}
assert_equal 0 [r exists set3{t}]
assert_error "WRONGTYPE*" {r SDIFFSTORE set3{t} noset{t} key1{t}}
assert_equal 0 [r exists set3{t}]
# with a legal dstkey
r sadd set1{t} a b c
r sadd set2{t} b c d
r sadd set3{t} e
assert_error "WRONGTYPE*" {r SDIFFSTORE set3{t} key1{t} set1{t} noset{t}
}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
assert_error "WRONGTYPE*" {r SDIFFSTORE set3{t} set1{t} key1{t} set2{t}}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
}
test "SDIFFSTORE should handle non existing key as empty" {
r del set1{t} set2{t} set3{t}
r set setres{t} xxx
assert_equal 0 [r sdiffstore setres{t} foo111{t} bar222{t}]
assert_equal 0 [r exists setres{t}]
# with a legal dstkey, should delete dstkey
r sadd set3{t} a b c
assert_equal 0 [r sdiffstore set3{t} set1{t} set2{t}]
assert_equal 0 [r exists set3{t}]
r sadd set1{t} a b c
assert_equal 3 [r sdiffstore set3{t} set1{t} set2{t}]
assert_equal 1 [r exists set3{t}]
assert_equal {a b c} [lsort [r smembers set3{t}]]
# with a legal dstkey and empty set2, should delete the dstkey
r sadd set3{t} a b c
assert_equal 0 [r sdiffstore set3{t} set2{t} set1{t}]
assert_equal 0 [r exists set3{t}]
} }
test "SUNION against non-set should throw error" { test "SINTER against non-set should throw error" {
r set key1 x r set key1{t} x
assert_error "WRONGTYPE*" {r sunion key1 noset} assert_error "WRONGTYPE*" {r sinter key1{t} noset{t}}
# different order
assert_error "WRONGTYPE*" {r sinter noset{t} key1{t}}
r sadd set1{t} a b c
assert_error "WRONGTYPE*" {r sinter key1{t} set1{t}}
# different order
assert_error "WRONGTYPE*" {r sinter set1{t} key1{t}}
} }
test "SINTER should handle non existing key as empty" { test "SINTER should handle non existing key as empty" {
r del set1 set2 set3 r del set1 set2 set3
r sadd set1 a b c r sadd set1 a b c
r sadd set2 b c d r sadd set2 b c d
r sinter set1 set2 set3 r sinter set1 set2 set3
} {} } {}
test "SINTER with same integer elements but different encoding" { test "SINTER with same integer elements but different encoding" {
r del set1 set2 r del set1 set2
r sadd set1 1 2 3 r sadd set1 1 2 3
r sadd set2 1 2 3 a r sadd set2 1 2 3 a
r srem set2 a r srem set2 a
assert_encoding intset set1 assert_encoding intset set1
assert_encoding hashtable set2 assert_encoding hashtable set2
lsort [r sinter set1 set2] lsort [r sinter set1 set2]
} {1 2 3} } {1 2 3}
test "SINTERSTORE against non-set should throw error" {
r del set1{t} set2{t} set3{t} key1{t}
r set key1{t} x
# with en empty dstkey
assert_error "WRONGTYPE*" {r sinterstore set3{t} key1{t} noset{t}}
assert_equal 0 [r exists set3{t}]
assert_error "WRONGTYPE*" {r sinterstore set3{t} noset{t} key1{t}}
assert_equal 0 [r exists set3{t}]
# with a legal dstkey
r sadd set1{t} a b c
r sadd set2{t} b c d
r sadd set3{t} e
assert_error "WRONGTYPE*" {r sinterstore set3{t} key1{t} set2{t} noset{t
}}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
assert_error "WRONGTYPE*" {r sinterstore set3{t} noset{t} key1{t} set2{t
}}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
}
test "SINTERSTORE against non existing keys should delete dstkey" { test "SINTERSTORE against non existing keys should delete dstkey" {
r set setres xxx r del set1{t} set2{t} set3{t}
assert_equal 0 [r sinterstore setres foo111 bar222]
assert_equal 0 [r exists setres] r set setres{t} xxx
assert_equal 0 [r sinterstore setres{t} foo111{t} bar222{t}]
assert_equal 0 [r exists setres{t}]
# with a legal dstkey
r sadd set3{t} a b c
assert_equal 0 [r sinterstore set3{t} set1{t} set2{t}]
assert_equal 0 [r exists set3{t}]
r sadd set1{t} a b c
assert_equal 0 [r sinterstore set3{t} set1{t} set2{t}]
assert_equal 0 [r exists set3{t}]
assert_equal 0 [r sinterstore set3{t} set2{t} set1{t}]
assert_equal 0 [r exists set3{t}]
}
test "SUNION against non-set should throw error" {
r set key1{t} x
assert_error "WRONGTYPE*" {r sunion key1{t} noset{t}}
# different order
assert_error "WRONGTYPE*" {r sunion noset{t} key1{t}}
r del set1{t}
r sadd set1{t} a b c
assert_error "WRONGTYPE*" {r sunion key1{t} set1{t}}
# different order
assert_error "WRONGTYPE*" {r sunion set1{t} key1{t}}
}
test "SUNION should handle non existing key as empty" {
r del set1{t} set2{t} set3{t}
r sadd set1{t} a b c
r sadd set2{t} b c d
assert_equal {a b c d} [lsort [r sunion set1{t} set2{t} set3{t}]]
}
test "SUNIONSTORE against non-set should throw error" {
r del set1{t} set2{t} set3{t} key1{t}
r set key1{t} x
# with en empty dstkey
assert_error "WRONGTYPE*" {r sunionstore set3{t} key1{t} noset{t}}
assert_equal 0 [r exists set3{t}]
assert_error "WRONGTYPE*" {r sunionstore set3{t} noset{t} key1{t}}
assert_equal 0 [r exists set3{t}]
# with a legal dstkey
r sadd set1{t} a b c
r sadd set2{t} b c d
r sadd set3{t} e
assert_error "WRONGTYPE*" {r sunionstore set3{t} key1{t} key2{t} noset{t
}}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
assert_error "WRONGTYPE*" {r sunionstore set3{t} noset{t} key1{t} key2{t
}}
assert_equal 1 [r exists set3{t}]
assert_equal {e} [lsort [r smembers set3{t}]]
}
test "SUNIONSTORE should handle non existing key as empty" {
r del set1{t} set2{t} set3{t}
r set setres{t} xxx
assert_equal 0 [r sunionstore setres{t} foo111{t} bar222{t}]
assert_equal 0 [r exists setres{t}]
# set1 set2 both empty, should delete the dstkey
r sadd set3{t} a b c
assert_equal 0 [r sunionstore set3{t} set1{t} set2{t}]
assert_equal 0 [r exists set3{t}]
r sadd set1{t} a b c
r sadd set3{t} e f
assert_equal 3 [r sunionstore set3{t} set1{t} set2{t}]
assert_equal 1 [r exists set3{t}]
assert_equal {a b c} [lsort [r smembers set3{t}]]
r sadd set3{t} d
assert_equal 3 [r sunionstore set3{t} set2{t} set1{t}]
assert_equal 1 [r exists set3{t}]
assert_equal {a b c} [lsort [r smembers set3{t}]]
} }
test "SUNIONSTORE against non existing keys should delete dstkey" { test "SUNIONSTORE against non existing keys should delete dstkey" {
r set setres xxx r set setres xxx
assert_equal 0 [r sunionstore setres foo111 bar222] assert_equal 0 [r sunionstore setres foo111 bar222]
assert_equal 0 [r exists setres] assert_equal 0 [r exists setres]
} }
foreach {type contents} {hashtable {a b c} intset {1 2 3}} { foreach {type contents} {hashtable {a b c} intset {1 2 3}} {
test "SPOP basics - $type" { test "SPOP basics - $type" {
skipping to change at line 406 skipping to change at line 583
test "SPOP new implementation: code path #3" { 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} 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 create_set myset $content
set res [r spop myset 18] set res [r spop myset 18]
assert {[llength $res] == 18} assert {[llength $res] == 18}
assert {[r scard myset] == 2} assert {[r scard myset] == 2}
set union [concat [r smembers myset] $res] set union [concat [r smembers myset] $res]
assert {[lsort $union] eq [lsort $content]} assert {[lsort $union] eq [lsort $content]}
} }
test "SRANDMEMBER count of 0 is handled correctly" {
r srandmember myset 0
} {}
test "SRANDMEMBER with <count> against non existing key" { test "SRANDMEMBER with <count> against non existing key" {
r srandmember nonexisting_key 100 r srandmember nonexisting_key 100
} {} } {}
# Make sure we can distinguish between an empty array and a null response
r readraw 1
test "SRANDMEMBER count of 0 is handled correctly - emptyarray" {
r srandmember myset 0
} {*0}
test "SRANDMEMBER with <count> against non existing key - emptyarray" {
r srandmember nonexisting_key 100
} {*0}
r readraw 0
foreach {type contents} { foreach {type contents} {
hashtable { hashtable {
1 5 10 50 125 50000 33959417 4775547 65434162 1 5 10 50 125 50000 33959417 4775547 65434162
12098459 427716 483706 2726473884 72615637475 12098459 427716 483706 2726473884 72615637475
MARY PATRICIA LINDA BARBARA ELIZABETH JENNIFER MARIA MARY PATRICIA LINDA BARBARA ELIZABETH JENNIFER MARIA
SUSAN MARGARET DOROTHY LISA NANCY KAREN BETTY HELEN SUSAN MARGARET DOROTHY LISA NANCY KAREN BETTY HELEN
SANDRA DONNA CAROL RUTH SHARON MICHELLE LAURA SARAH SANDRA DONNA CAROL RUTH SHARON MICHELLE LAURA SARAH
KIMBERLY DEBORAH JESSICA SHIRLEY CYNTHIA ANGELA MELISSA KIMBERLY DEBORAH JESSICA SHIRLEY CYNTHIA ANGELA MELISSA
BRENDA AMY ANNA REBECCA VIRGINIA KATHLEEN BRENDA AMY ANNA REBECCA VIRGINIA KATHLEEN
} }
skipping to change at line 635 skipping to change at line 829
assert_error "WRONGTYPE*" {r smove myset2 x foo} assert_error "WRONGTYPE*" {r smove myset2 x foo}
} }
test "SMOVE with identical source and destination" { test "SMOVE with identical source and destination" {
r del set r del set
r sadd set a b c r sadd set a b c
r smove set set b r smove set set b
lsort [r smembers set] lsort [r smembers set]
} {a b c} } {a b c}
test "SMOVE only notify dstset when the addition is successful" {
r del srcset{t}
r del dstset{t}
r sadd srcset{t} a b
r sadd dstset{t} a
r watch dstset{t}
r multi
r sadd dstset{t} c
set r2 [redis_client]
$r2 smove srcset{t} dstset{t} a
# The dstset is actually unchanged, multi should success
r exec
set res [r scard dstset{t}]
assert_equal $res 2
$r2 close
}
tags {slow} { tags {slow} {
test {intsets implementation stress testing} { test {intsets implementation stress testing} {
for {set j 0} {$j < 20} {incr j} { for {set j 0} {$j < 20} {incr j} {
unset -nocomplain s unset -nocomplain s
array set s {} array set s {}
r del s r del s
set len [randomInt 1024] set len [randomInt 1024]
for {set i 0} {$i < $len} {incr i} { for {set i 0} {$i < $len} {incr i} {
randpath { randpath {
set data [randomInt 65536] set data [randomInt 65536]
 End of changes. 7 change blocks. 
9 lines changed or deleted 230 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)