def test_union1(self):
        a = CountingFilter(n, p)
        b = CountingFilter(n, p)
        for i in range(1000):
            a.insert(str(i))

        for i in range(1000, 2000):
            b.insert(str(i))

        a.union(b)

        # If the union Bloom Filter actually contains an element, it should always say it does
        for i in range(2000):
            self.assertTrue(a.contains(str(i)))

        # If a Bloom Filter does not contain an element, there is a chance of false positives, which will be calculated
        # by the get_false_positive_rate method
        errors = 0
        for i in range(-1, -1001, -1):
            if a.contains(str(i)):
                errors = errors + 1
        print("number of errors is" ,errors)
        fpr = self.get_false_positive_rate(n * 2, a.getBitSize(), a.getHashCount())
        print("false positive rate is ", fpr)
        self.assertTrue(errors < n * (fpr + buffer))
 def test_check_Union(self):
     a = CountingFilter(n, p)
     a.insert(str(1034))
     a.insert(str(1034))
     b = CountingFilter(n, p)
     b.insert(str(1034))
     b.insert(str(1034))
     a.union(b)
     ret = a.howMany(str(1034))
     self.assertTrue(ret == 4)