-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from uktrade/fix/reliable-int-mapping
Fix/reliable int mapping
- Loading branch information
Showing
4 changed files
with
112 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from matchbox.common.hash import IntMap | ||
|
||
|
||
def test_intmap_basic(): | ||
im1 = IntMap(salt=10) | ||
a = im1.index(1, 2) | ||
b = im1.index(3, 4) | ||
c = im1.index(a, b) | ||
|
||
assert len({a, b, c}) == 3 | ||
assert max(a, b, c) < 0 | ||
|
||
|
||
def test_intmap_same(): | ||
im1 = IntMap(salt=10) | ||
a = im1.index(1, 2) | ||
b = im1.index(3, 4) | ||
c = im1.index(a, b) | ||
|
||
im2 = IntMap(salt=10) | ||
x = im2.index(1, 2) | ||
y = im2.index(3, 4) | ||
z = im2.index(a, b) | ||
|
||
assert (a, b, c) == (x, y, z) | ||
|
||
|
||
def test_intmap_different(): | ||
im1 = IntMap(salt=10) | ||
a = im1.index(1, 2) | ||
b = im1.index(3, 4) | ||
c = im1.index(a, b) | ||
|
||
im2 = IntMap(salt=11) | ||
x = im2.index(1, 2) | ||
y = im2.index(3, 4) | ||
z = im2.index(a, b) | ||
|
||
for v1, v2 in zip([a, b, c], [x, y, z], strict=True): | ||
assert v1 != v2 | ||
|
||
|
||
def test_intmap_unordered(): | ||
im1 = IntMap(salt=10) | ||
a = im1.index(1, 2, 3) | ||
b = im1.index(3, 1, 2) | ||
|
||
assert a == b |