Skip to content

Commit

Permalink
test: add NotBijection test
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Jul 1, 2024
1 parent cc62d49 commit 006b94c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion hugr-py/tests/test_bimap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from hugr.utils import BiMap
import pytest

from hugr.utils import BiMap, NotBijection


def test_insert_left() -> None:
Expand Down Expand Up @@ -61,3 +63,19 @@ def test_existing_key() -> None:
assert bimap.get_left(1) == "b"

assert bimap.get_right("a") is None


def test_bimap_init():
# Test with empty initial map
bm = BiMap()
assert len(bm) == 0

# Test with non-empty initial map
initial_map = {"a": 1, "b": 2}
bm = BiMap(initial_map)
assert len(bm) == 2

# Test with non-bijection initial map
invalid_map = {"a": 1, "b": 1}
with pytest.raises(NotBijection):
bm = BiMap(invalid_map)

0 comments on commit 006b94c

Please sign in to comment.