File: hyper_log_log.rb

package info (click to toggle)
ruby-redis 3.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 736 kB
  • ctags: 1,128
  • sloc: ruby: 8,149; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download | duplicates (2)
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
module Lint

  module HyperLogLog

    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

  end

end