fix: improve pathfinding test

This commit is contained in:
punchready 2021-06-03 02:56:09 +02:00
parent 1601a2560d
commit b80b96a3a0

View File

@ -208,23 +208,17 @@ class GameLogicTest {
ArrayList<IntVector2> result = GameLogic.Bresenham4Connected(a, b); ArrayList<IntVector2> result = GameLogic.Bresenham4Connected(a, b);
StringBuilder sb = new StringBuilder(); assertEquals(result.get(0), a, "Start point should be point A");
for(int y = 0; y < size; y++) { assertEquals(result.get(result.size() - 1), b, "End point should be point B");
for(int x = 0; x < size; x++) {
IntVector2 pos = new IntVector2(x, y); IntVector2 old = a;
if(pos.equals(a)) { for(IntVector2 pos: result) {
sb.append("A "); if(pos.equals(a)) {
}else if(pos.equals(b)) { continue;
sb.append("B ");
}else if(result.contains(pos)) {
sb.append("o ");
}else {
sb.append(". ");
}
} }
sb.append("\n"); assertEquals(1, old.distanceManhattan(pos), "Distance between every step should be 1");
old = pos;
} }
System.out.println(sb.toString());
} }