diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 12:35:28 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 12:35:28 +0200 |
commit | dc1a5978f40c8021895bc60b8802e64c6b43e805 (patch) | |
tree | 4f08a79cdfe4d7041a5a2bae6ee99acad2448494 /core/test/ch/asynk/tankontank | |
parent | 29f2682c2c60b205a7e7fe69909ca338d21e1c41 (diff) | |
download | RustAndDust-dc1a5978f40c8021895bc60b8802e64c6b43e805.zip RustAndDust-dc1a5978f40c8021895bc60b8802e64c6b43e805.tar.gz |
fix tests
Diffstat (limited to 'core/test/ch/asynk/tankontank')
-rw-r--r-- | core/test/ch/asynk/tankontank/BoardUtils.java | 73 | ||||
-rw-r--r-- | core/test/ch/asynk/tankontank/Helpers.java | 1 |
2 files changed, 43 insertions, 31 deletions
diff --git a/core/test/ch/asynk/tankontank/BoardUtils.java b/core/test/ch/asynk/tankontank/BoardUtils.java index 3f4ca7e..f691cbf 100644 --- a/core/test/ch/asynk/tankontank/BoardUtils.java +++ b/core/test/ch/asynk/tankontank/BoardUtils.java @@ -39,11 +39,11 @@ public class BoardUtils assertTrue((path.size() == 3) || (path.size() == 4)); SearchBoard.Node n = path.get(0); - assertTrue(n.col == 4); - assertTrue(n.row == 3); - n = path.get(path.size() - 1); assertTrue(n.col == 2); assertTrue(n.row == 2); + n = path.get(path.size() - 1); + assertTrue(n.col == 4); + assertTrue(n.row == 3); int i = 1; if (path.size() == 3) { @@ -59,44 +59,33 @@ public class BoardUtils assert(n.col == 3); assert(n.row == 2); } else { - assert(n.col == 3); + assert(n.row == 3); n = path.get(i); - assert(n.col == 2); + assert(n.col == 3); assert(n.row == 3); } } else if (n.col == 3) { i += 1; if (n.row == 2) { n = path.get(i); - if (n.col == 2) - assert(n.row == 1); - else { - assert(n.col == 3); + if (n.col == 3) assert(n.row == 3); + else { + assert(n.col == 4); + assert(n.row == 2); } } else { - assert(n.col == 3); + assert(n.row == 3); n = path.get(i); - if (n.col == 2) - assert(n.row == 3); - else { - assert(n.col == 3); + if (n.col == 3) assert(n.row == 2); + else { + assert(n.col == 4); + assert(n.row == 4); } } } else { - i += 1; - assertTrue(n.col == 4); - if (n.row == 4) { - n = path.get(i); - assert(n.col == 3); - assert(n.row == 3); - } else { - assert(n.row == 2); - n = path.get(i); - assert(n.col == 3); - assert(n.row == 2); - } + assertTrue(false); } } } @@ -109,21 +98,43 @@ public class BoardUtils HashSet<GridPoint2> points = new HashSet<GridPoint2>(); GridPoint2 from = new GridPoint2(2, 2); - GridPoint2 to = new GridPoint2(4, 3); + GridPoint2 to = new GridPoint2(3, 3); int n = b.possiblePaths(p, from, to, points); + assertTrue(n == 1); + assertTrue(points.size() == 2); + + to.set(4, 3); + + n = b.possiblePaths(p, from, to, points); assertTrue(n == 8); assertTrue(points.size() == 8); GridPoint2 p0 = new GridPoint2(3, 3); n = b.possiblePathsFilterToggle(p0, points); - assertTrue(n == 5); - assertTrue(points.size() == 6); - GridPoint2 p1 = new GridPoint2(4, 4); + assertTrue(n == 1); + assertTrue(points.size() == 3); + + to.set(5, 3); + + n = b.possiblePaths(p, from, to, points); + assertTrue(n == 3); + + p0.set(3, 3); + n = b.possiblePathsFilterToggle(p0, points); + assertTrue(n == 1); + n = b.possiblePathsFilterToggle(p0, points); + assertTrue(n == 3); + + GridPoint2 p1 = new GridPoint2(3, 2); n = b.possiblePathsFilterToggle(p1, points); + assertTrue(n == 2); + + GridPoint2 p2 = new GridPoint2(4, 2); + n = b.possiblePathsFilterToggle(p2, points); assertTrue(n == 1); - assertTrue(points.size() == 4); + } @Test diff --git a/core/test/ch/asynk/tankontank/Helpers.java b/core/test/ch/asynk/tankontank/Helpers.java index b8699cd..4af317f 100644 --- a/core/test/ch/asynk/tankontank/Helpers.java +++ b/core/test/ch/asynk/tankontank/Helpers.java @@ -20,6 +20,7 @@ public class Helpers public int getRoadMarchBonus() { return 1; } public boolean isUnit() { return true; } public boolean isEnemy(Pawn other) { return true; } + public boolean canAttack(Pawn other) { return true; } public int getAngleOfAttack() { return 0; } public int getAttackRangeFrom(Tile tile) { return 3; } } |