Sha256: 2c124c56e29ebb748cba3b61418754a2159b4955f4007432e4dc0a4aeee47441

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

require_relative "helper"

class TestCommandsOnHyperLogLog < Test::Unit::TestCase

  include Helper::Client

  def test_pfadd
    target_version "2.8.9" do
      assert_equal true, r.pfadd("foo", "s1")
      assert_equal true, r.pfadd("foo", "s2")
      assert_equal false, r.pfadd("foo", "s1")

      assert_equal 2, r.pfcount("foo")
    end
  end

  def test_variadic_pfadd
    target_version "2.8.9" do
      assert_equal true, r.pfadd("foo", ["s1", "s2"])
      assert_equal true, r.pfadd("foo", ["s1", "s2", "s3"])

      assert_equal 3, r.pfcount("foo")
    end
  end

  def test_pfcount
    target_version "2.8.9" do
      assert_equal 0, r.pfcount("foo")

      assert_equal true, r.pfadd("foo", "s1")

      assert_equal 1, r.pfcount("foo")
    end
  end

  def test_variadic_pfcount
    target_version "2.8.9" do
      assert_equal 0, r.pfcount(["{1}foo", "{1}bar"])

      assert_equal true, r.pfadd("{1}foo", "s1")
      assert_equal true, r.pfadd("{1}bar", "s1")
      assert_equal true, r.pfadd("{1}bar", "s2")

      assert_equal 2, r.pfcount("{1}foo", "{1}bar")
    end
  end

  def test_variadic_pfcount_expanded
    target_version "2.8.9" do
      assert_equal 0, r.pfcount("{1}foo", "{1}bar")

      assert_equal true, r.pfadd("{1}foo", "s1")
      assert_equal true, r.pfadd("{1}bar", "s1")
      assert_equal true, r.pfadd("{1}bar", "s2")

      assert_equal 2, r.pfcount("{1}foo", "{1}bar")
    end
  end

  def test_pfmerge
    target_version "2.8.9" do
      r.pfadd "foo", "s1"
      r.pfadd "bar", "s2"

      assert_equal true, r.pfmerge("res", "foo", "bar")
      assert_equal 2, r.pfcount("res")
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis-4.0.0.rc1 test/commands_on_hyper_log_log_test.rb