Skip to content

Commit 52dfaef

Browse files
authored
Add test_hash_eq_after_operations (#132)
This validates the fix for issue #129
1 parent c12f08d commit 52dfaef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,17 @@ def test_hash_eq2(self) -> None:
12211221
assert bm1.get_statistics() != bm2.get_statistics()
12221222
assert hash(bm1) == hash(bm2)
12231223

1224+
def test_hash_eq_after_operations(self) -> None:
1225+
"""Testing that bitmaps have the same hash even when they have been obtained after some operations.
1226+
Test for issue #129.
1227+
"""
1228+
ref_hash = hash(FrozenBitMap([2, 3]))
1229+
assert ref_hash == hash(FrozenBitMap([1, 2, 3]) & FrozenBitMap([2, 3, 4]))
1230+
assert ref_hash == hash(FrozenBitMap([1, 2, 3]).intersection(FrozenBitMap([2, 3, 4]), FrozenBitMap([0, 2, 3])))
1231+
assert ref_hash == hash(FrozenBitMap([2]) | FrozenBitMap([3]))
1232+
assert ref_hash == hash(FrozenBitMap([2]).union(FrozenBitMap([3]), FrozenBitMap()))
1233+
assert ref_hash == hash(FrozenBitMap([1, 2, 3, 4]) - FrozenBitMap([1, 4]))
1234+
assert ref_hash == hash(FrozenBitMap([1, 2, 3, 4]).difference(FrozenBitMap([1]), FrozenBitMap([4])))
12241235

12251236
class TestOptimization:
12261237

0 commit comments

Comments
 (0)