test/lint/sets.rb in redis-3.0.0.rc1 vs test/lint/sets.rb in redis-3.0.0.rc2
- old
+ new
@@ -1,90 +1,96 @@
-test "SADD" do |r|
- assert true == r.sadd("foo", "s1")
- assert true == r.sadd("foo", "s2")
- assert false == r.sadd("foo", "s1")
+module Lint
- assert ["s1", "s2"] == r.smembers("foo").sort
-end
+ module Sets
-test "Variadic SADD" do |r|
- next if version(r) < 203090 # 2.4-rc6
+ def test_sadd
+ assert_equal true, r.sadd("foo", "s1")
+ assert_equal true, r.sadd("foo", "s2")
+ assert_equal false, r.sadd("foo", "s1")
- assert 2 == r.sadd("foo", ["s1", "s2"])
- assert 1 == r.sadd("foo", ["s1", "s2", "s3"])
+ assert_equal ["s1", "s2"], r.smembers("foo").sort
+ end
- assert ["s1", "s2", "s3"] == r.smembers("foo").sort
-end
+ def test_variadic_sadd
+ return if version < "2.3.9" # 2.4-rc6
-test "SREM" do |r|
- r.sadd("foo", "s1")
- r.sadd("foo", "s2")
+ assert_equal 2, r.sadd("foo", ["s1", "s2"])
+ assert_equal 1, r.sadd("foo", ["s1", "s2", "s3"])
- assert true == r.srem("foo", "s1")
- assert false == r.srem("foo", "s3")
+ assert_equal ["s1", "s2", "s3"], r.smembers("foo").sort
+ end
- assert ["s2"] == r.smembers("foo")
-end
+ def test_srem
+ r.sadd("foo", "s1")
+ r.sadd("foo", "s2")
-test "Variadic SREM" do |r|
- next if version(r) < 203090 # 2.4-rc6
+ assert_equal true, r.srem("foo", "s1")
+ assert_equal false, r.srem("foo", "s3")
- r.sadd("foo", "s1")
- r.sadd("foo", "s2")
- r.sadd("foo", "s3")
+ assert_equal ["s2"], r.smembers("foo")
+ end
- assert 1 == r.srem("foo", ["s1", "aaa"])
- assert 0 == r.srem("foo", ["bbb", "ccc" "ddd"])
- assert 1 == r.srem("foo", ["eee", "s3"])
+ def test_variadic_srem
+ return if version < "2.3.9" # 2.4-rc6
- assert ["s2"] == r.smembers("foo")
-end
+ r.sadd("foo", "s1")
+ r.sadd("foo", "s2")
+ r.sadd("foo", "s3")
-test "SPOP" do |r|
- r.sadd "foo", "s1"
- r.sadd "foo", "s2"
+ assert_equal 1, r.srem("foo", ["s1", "aaa"])
+ assert_equal 0, r.srem("foo", ["bbb", "ccc" "ddd"])
+ assert_equal 1, r.srem("foo", ["eee", "s3"])
- assert ["s1", "s2"].include?(r.spop("foo"))
- assert ["s1", "s2"].include?(r.spop("foo"))
- assert nil == r.spop("foo")
-end
+ assert_equal ["s2"], r.smembers("foo")
+ end
-test "SCARD" do |r|
- assert 0 == r.scard("foo")
+ def test_spop
+ r.sadd "foo", "s1"
+ r.sadd "foo", "s2"
- r.sadd "foo", "s1"
+ assert ["s1", "s2"].include?(r.spop("foo"))
+ assert ["s1", "s2"].include?(r.spop("foo"))
+ assert_equal nil, r.spop("foo")
+ end
- assert 1 == r.scard("foo")
+ def test_scard
+ assert_equal 0, r.scard("foo")
- r.sadd "foo", "s2"
+ r.sadd "foo", "s1"
- assert 2 == r.scard("foo")
-end
+ assert_equal 1, r.scard("foo")
-test "SISMEMBER" do |r|
- assert false == r.sismember("foo", "s1")
+ r.sadd "foo", "s2"
- r.sadd "foo", "s1"
+ assert_equal 2, r.scard("foo")
+ end
- assert true == r.sismember("foo", "s1")
- assert false == r.sismember("foo", "s2")
-end
+ def test_sismember
+ assert_equal false, r.sismember("foo", "s1")
-test "SMEMBERS" do |r|
- assert [] == r.smembers("foo")
+ r.sadd "foo", "s1"
- r.sadd "foo", "s1"
- r.sadd "foo", "s2"
+ assert_equal true, r.sismember("foo", "s1")
+ assert_equal false, r.sismember("foo", "s2")
+ end
- assert ["s1", "s2"] == r.smembers("foo").sort
-end
+ def test_smembers
+ assert_equal [], r.smembers("foo")
-test "SRANDMEMBER" do |r|
- r.sadd "foo", "s1"
- r.sadd "foo", "s2"
+ r.sadd "foo", "s1"
+ r.sadd "foo", "s2"
- 4.times do
- assert ["s1", "s2"].include?(r.srandmember("foo"))
- end
+ assert_equal ["s1", "s2"], r.smembers("foo").sort
+ end
- assert 2 == r.scard("foo")
+ def test_srandmember
+ r.sadd "foo", "s1"
+ r.sadd "foo", "s2"
+
+ 4.times do
+ assert ["s1", "s2"].include?(r.srandmember("foo"))
+ end
+
+ assert_equal 2, r.scard("foo")
+ end
+ end
end