Skip to content

Commit

Permalink
expandingbloom non-default hash test
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Dec 22, 2024
1 parent 3a8ea1d commit f015587
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/expandingbloom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from probables import ExpandingBloomFilter, RotatingBloomFilter
from probables.exceptions import RotatingBloomFilterError
from tests.utilities import calc_file_md5
from tests.utilities import calc_file_md5, different_hash

DELETE_TEMP_FILES = True

Expand All @@ -38,6 +38,13 @@ def test_ebf_add_lots(self):
blm.add("{}".format(i), True)
self.assertEqual(blm.expansions, 9)

def test_ebf_add_lots_diff_hash(self):
"""test adding "lots" of elements to force the expansion using a different hash"""
blm = ExpandingBloomFilter(est_elements=10, false_positive_rate=0.05, hash_function=different_hash)
for i in range(100):
blm.add("{}".format(i), True)
self.assertEqual(blm.expansions, 9)

def test_ebf_add_lots_without_force(self):
"""testing adding "lots" but force them to be inserted multiple times"""
blm = ExpandingBloomFilter(est_elements=10, false_positive_rate=0.05)
Expand Down

0 comments on commit f015587

Please sign in to comment.