helpers test cases parametrization
This commit is contained in:
parent
63596fae3c
commit
03b6d66c5b
1 changed files with 50 additions and 10 deletions
|
@ -1,18 +1,58 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
from pigeon_magnet_solver.helpers import (_fix_exes, _rotate_r, _valid_rotate,
|
from pigeon_magnet_solver.helpers import (_fix_exes, _rotate_r, _valid_rotate,
|
||||||
rotate_r)
|
rotate_r)
|
||||||
|
|
||||||
|
|
||||||
def test_rotate_r():
|
@pytest.mark.parametrize("test_input,expected", [
|
||||||
assert _rotate_r(list("1x01")) == list("11x0")
|
# trivial cases
|
||||||
assert _rotate_r(list("11x0")) == list("011x")
|
("1111", "1111"),
|
||||||
assert _rotate_r(list("011x")) == list("x011")
|
("0000", "0000"),
|
||||||
assert _rotate_r(list("x011")) == list("1x01")
|
("xxxx", "xxxx"),
|
||||||
|
|
||||||
assert _valid_rotate(list("1x01"), list("11x0")) is False
|
# interesting case "1x01"
|
||||||
assert _valid_rotate(list("1x01"), list("011x")) is False
|
("1x01", "11x0"),
|
||||||
assert _valid_rotate(list("1x01"), list("x011")) is True
|
("11x0", "011x"),
|
||||||
assert _valid_rotate(list("1x01"), list("1x01")) is True
|
("011x", "x011"),
|
||||||
|
("x011", "1x01"),
|
||||||
|
])
|
||||||
|
def test__rotate_r(test_input: str, expected: str):
|
||||||
|
assert _rotate_r(list(test_input)) == list(expected)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("test_input,candidate,expected", [
|
||||||
|
# interesting case "1x01"
|
||||||
|
("1x01", "11x0", False),
|
||||||
|
("1x01", "011x", False),
|
||||||
|
("1x01", "x011", True),
|
||||||
|
("1x01", "1x01", True),
|
||||||
|
])
|
||||||
|
def test__valid_rotate(test_input: str, candidate: str, expected: bool):
|
||||||
|
assert _valid_rotate(list(test_input), list(candidate)) is expected
|
||||||
|
|
||||||
|
|
||||||
|
def test__fix_exes():
|
||||||
assert _fix_exes(list("1x01"), list("x011")) == list("0x11")
|
assert _fix_exes(list("1x01"), list("x011")) == list("0x11")
|
||||||
|
|
||||||
assert rotate_r(list("1x01")) == list("0x11")
|
|
||||||
|
@pytest.mark.parametrize("test_input,expected", [
|
||||||
|
# trivial cases
|
||||||
|
("1111", "1111"),
|
||||||
|
("0000", "0000"),
|
||||||
|
("xxxx", "xxxx"),
|
||||||
|
|
||||||
|
# fixpoints "1x10"
|
||||||
|
("1x10", "1x10"),
|
||||||
|
("101x", "101x"),
|
||||||
|
("1x1x", "1x1x"),
|
||||||
|
|
||||||
|
# alternating case "1010"
|
||||||
|
("1010", "0101"),
|
||||||
|
("0101", "1010"),
|
||||||
|
|
||||||
|
# interesting case "1x01"
|
||||||
|
("1x01", "0x11"),
|
||||||
|
("0x11", "1x01"),
|
||||||
|
])
|
||||||
|
def test_rotate_r(test_input: str, expected: str):
|
||||||
|
assert rotate_r(list(test_input)) == list(expected)
|
||||||
|
|
Loading…
Reference in a new issue