1 start_server
default.conf
{} {
2 test
{SADD
, SCARD
, SISMEMBER
, SMEMBERS basics
} {
5 list [r scard myset
] [r sismember myset foo
] \
6 [r sismember myset bar
] [r sismember myset bla
] \
7 [lsort [r smembers myset
]]
10 test
{SADD adding the same element multiple times
} {
17 test
{SADD against non
set} {
19 catch {r sadd mylist bar
} err
26 lsort [r smembers myset
]
29 test
{Mass SADD and SINTER with two sets
} {
30 for {set i
0} {$i < 1000} {incr i
} {
32 r sadd set2
[expr $i+995]
34 lsort [r sinter set1 set2
]
35 } {995 996 997 998 999}
37 test
{SUNION with two sets
} {
38 lsort [r sunion set1 set2
]
39 } [lsort -uniq "[r smembers set1] [r smembers set2]"]
41 test
{SINTERSTORE with two sets
} {
42 r sinterstore setres set1 set2
43 lsort [r smembers setres
]
44 } {995 996 997 998 999}
46 test
{SINTERSTORE with two sets
, after a DEBUG RELOAD
} {
48 r sinterstore setres set1 set2
49 lsort [r smembers setres
]
50 } {995 996 997 998 999}
52 test
{SUNIONSTORE with two sets
} {
53 r sunionstore setres set1 set2
54 lsort [r smembers setres
]
55 } [lsort -uniq "[r smembers set1] [r smembers set2]"]
57 test
{SUNIONSTORE against non existing keys
} {
59 list [r sunionstore setres foo111 bar222
] [r exists xxx
]
62 test
{SINTER against three sets
} {
67 lsort [r sinter set1 set2 set3
]
70 test
{SINTERSTORE with three sets
} {
71 r sinterstore setres set1 set2 set3
72 lsort [r smembers setres
]
75 test
{SUNION with non existing keys
} {
76 lsort [r sunion nokey1 set1 set2 nokey2
]
77 } [lsort -uniq "[r smembers set1] [r smembers set2]"]
79 test
{SDIFF with two sets
} {
80 for {set i
5} {$i < 1000} {incr i
} {
83 lsort [r sdiff set1 set4
]
86 test
{SDIFF with three sets
} {
88 lsort [r sdiff set1 set4 set5
]
91 test
{SDIFFSTORE with three sets
} {
92 r sdiffstore sres set1 set4 set5
93 lsort [r smembers sres
]
101 list [lsort [list [r spop myset
] [r spop myset
] [r spop myset
]]] [r scard myset
]
109 unset -nocomplain myset
111 for {set i
0} {$i < 100} {incr i
} {
112 set myset
([r srandmember myset
]) 1
114 lsort [array names myset
]
117 test
{SMOVE basics
} {
124 r smove myset1 myset2 a
125 list [lsort [r smembers myset2
]] [lsort [r smembers myset1
]]
128 test
{SMOVE non existing key
} {
129 list [r smove myset1 myset2 foo
] [lsort [r smembers myset2
]] [lsort [r smembers myset1
]]
130 } {0 {a x y z
} {b c
}}
132 test
{SMOVE non existing src
set} {
133 list [r smove noset myset2 foo
] [lsort [r smembers myset2
]]
136 test
{SMOVE non existing dst
set} {
137 list [r smove myset2 myset3 y
] [lsort [r smembers myset2
]] [lsort [r smembers myset3
]]
140 test
{SMOVE wrong src key type
} {
142 catch {r smove x myset2 foo
} err
146 test
{SMOVE wrong dst key type
} {
148 catch {r smove myset2 x foo
} err