fix: improve pathfinding test

This commit is contained in:
punchready 2021-06-03 02:56:09 +02:00
parent 1601a2560d
commit b80b96a3a0
1 changed files with 9 additions and 15 deletions

View File

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