From b80b96a3a0c44c6956a171645e0cc6093ff0bf89 Mon Sep 17 00:00:00 2001 From: punchready Date: Thu, 3 Jun 2021 02:56:09 +0200 Subject: [PATCH] fix: improve pathfinding test --- .../gamelibrary/gamelogic/GameLogicTest.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogicTest.java b/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogicTest.java index 97af980..98b99db 100644 --- a/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogicTest.java +++ b/src/test/java/uulm/teamname/marvelous/gamelibrary/gamelogic/GameLogicTest.java @@ -208,23 +208,17 @@ class GameLogicTest { ArrayList 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()); }