Sha256: eb645b54f6b539a24ec08dff8603af3fc376e1740b0bc742ea1abfb2655d5cd3

Contents?: true

Size: 1.42 KB

Versions: 11

Compression:

Stored size: 1.42 KB

Contents

# encoding: UTF-8

require "helper"
require "lint/sets"

class TestCommandsOnSets < Test::Unit::TestCase

  include Helper::Client
  include Lint::Sets

  def test_smove
    r.sadd "foo", "s1"
    r.sadd "bar", "s2"

    assert r.smove("foo", "bar", "s1")
    assert r.sismember("bar", "s1")
  end

  def test_sinter
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"

    assert_equal ["s2"], r.sinter("foo", "bar")
  end

  def test_sinterstore
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"

    r.sinterstore("baz", "foo", "bar")

    assert_equal ["s2"], r.smembers("baz")
  end

  def test_sunion
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"
    r.sadd "bar", "s3"

    assert_equal ["s1", "s2", "s3"], r.sunion("foo", "bar").sort
  end

  def test_sunionstore
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"
    r.sadd "bar", "s3"

    r.sunionstore("baz", "foo", "bar")

    assert_equal ["s1", "s2", "s3"], r.smembers("baz").sort
  end

  def test_sdiff
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"
    r.sadd "bar", "s3"

    assert_equal ["s1"], r.sdiff("foo", "bar")
    assert_equal ["s3"], r.sdiff("bar", "foo")
  end

  def test_sdiffstore
    r.sadd "foo", "s1"
    r.sadd "foo", "s2"
    r.sadd "bar", "s2"
    r.sadd "bar", "s3"

    r.sdiffstore("baz", "foo", "bar")

    assert_equal ["s1"], r.smembers("baz")
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
redis-3.0.5 test/commands_on_sets_test.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/redis-3.0.4/test/commands_on_sets_test.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/redis-3.0.4/test/commands_on_sets_test.rb
redis-3.0.4 test/commands_on_sets_test.rb
redis-3.0.3 test/commands_on_sets_test.rb
remq-0.0.4 vendor/bundle/gems/redis-3.0.2/test/commands_on_sets_test.rb
remq-0.0.3 vendor/bundle/gems/redis-3.0.2/test/commands_on_sets_test.rb
redis-3.0.2 test/commands_on_sets_test.rb
redis-3.0.1 test/commands_on_sets_test.rb
redis-3.0.0 test/commands_on_sets_test.rb
redis-3.0.0.rc2 test/commands_on_sets_test.rb