diff options
Diffstat (limited to 'tests_solver')
-rw-r--r-- | tests_solver/test_solver.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests_solver/test_solver.py b/tests_solver/test_solver.py new file mode 100644 index 0000000..e2b45a5 --- /dev/null +++ b/tests_solver/test_solver.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.getcwd()) + +from solver import * + +def test_is_swappable(): + assert is_swappable(Kana("norm", "su"), Kana("norm", "su")) + assert is_swappable(Kana("froz", "su"), Kana("norm", "su")) + assert is_swappable(Kana("norm", "su"), Kana("empt")) + assert is_swappable(Kana("empt"), Kana("froz", "su")) + assert not is_swappable(Kana("norm", "su"), Kana("rock", "su")) + assert not is_swappable(Kana("froz", "su"), Kana("froz", "su")) + assert not is_swappable(Kana("empt"), Kana("empt")) + + +def test_kana_grid(): + + initial_grid = [ + kana_void , Kana("myst", "su"), kana_void , Kana("myst", "ko"), kana_void , + Kana("froz", "se"), Kana("empt" ), Kana("empt" ), Kana("empt" ), Kana("froz", "so"), + Kana("froz", "ku"), Kana("empt" ), Kana("empt" ), Kana("empt" ), Kana("froz", "no"), + kana_void , kana_void , Kana("rock", "ka"), kana_void , kana_void , + ] + initial_grid_size = 5, 4 + chain_target = 7 + + expected_grid = [ + kana_void , Kana("myst", "su"), kana_void , Kana("myst", "ko"), kana_void , + Kana("empt" ), Kana("empt" ), Kana("empt" ), Kana("froz", "se"), Kana("froz", "so"), + Kana("froz", "ku"), Kana("empt" ), Kana("empt" ), Kana("empt" ), Kana("froz", "no"), + kana_void , kana_void , Kana("rock", "ka"), kana_void , kana_void , + ] + + kanagrid_orig = KanaGrid(initial_grid_size, initial_grid) + kanagrid_new = kanagrid_orig.action(pos=(0, 1), action_type="right") + + print("kanagrid_orig") + print(kanagrid_orig) + print("kanagrid_new") + print(kanagrid_new) + print("expected_grid") + display_grid(expected_grid, initial_grid_size) + + assert kanagrid_new.grid == expected_grid + |