aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsolver.py41
-rw-r--r--tests_solver/test_solver.py49
2 files changed, 49 insertions, 41 deletions
diff --git a/solver.py b/solver.py
index 7bf7055..ff53960 100755
--- a/solver.py
+++ b/solver.py
@@ -55,16 +55,6 @@ def is_swappable(kana1, kana2):
return False
-def test_is_swappable():
- assert is_swappable(Kana("norm"), Kana("norm"))
- assert is_swappable(Kana("froz"), Kana("norm"))
- assert is_swappable(Kana("norm"), Kana("empt"))
- assert is_swappable(Kana("empt"), Kana("froz"))
- assert not is_swappable(Kana("norm"), Kana("rock"))
- assert not is_swappable(Kana("froz"), Kana("froz"))
- assert not is_swappable(Kana("empt"), Kana("empt"))
-
-
class KanaGrid:
valid_types_for_chain = ("froz", "norm", "rock")
@@ -235,37 +225,6 @@ class KanaGrid:
)
-def test_kana_grid():
-
- inital_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
-
-
def repr_grid(grid, grid_size):
lines = []
kana_iter = iter(grid)
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
+