forked from redis/redis-rb
-
Notifications
You must be signed in to change notification settings - Fork 10
/
commands_on_sets_test.rb
76 lines (56 loc) · 1.32 KB
/
commands_on_sets_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# encoding: UTF-8
require File.expand_path("./helper", File.dirname(__FILE__))
setup do
init Redis.new(OPTIONS)
end
load './test/lint/sets.rb'
test "SMOVE" do |r|
r.sadd "foo", "s1"
r.sadd "bar", "s2"
assert r.smove("foo", "bar", "s1")
assert r.sismember("bar", "s1")
end
test "SINTER" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
assert ["s2"] == r.sinter("foo", "bar")
end
test "SINTERSTORE" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
r.sinterstore("baz", "foo", "bar")
assert ["s2"] == r.smembers("baz")
end
test "SUNION" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
r.sadd "bar", "s3"
assert ["s1", "s2", "s3"] == r.sunion("foo", "bar").sort
end
test "SUNIONSTORE" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
r.sadd "bar", "s3"
r.sunionstore("baz", "foo", "bar")
assert ["s1", "s2", "s3"] == r.smembers("baz").sort
end
test "SDIFF" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
r.sadd "bar", "s3"
assert ["s1"] == r.sdiff("foo", "bar")
assert ["s3"] == r.sdiff("bar", "foo")
end
test "SDIFFSTORE" do |r|
r.sadd "foo", "s1"
r.sadd "foo", "s2"
r.sadd "bar", "s2"
r.sadd "bar", "s3"
r.sdiffstore("baz", "foo", "bar")
assert ["s1"] == r.smembers("baz")
end