From f9fc0507fbf5755770133b341898f0d974eb4c75 Mon Sep 17 00:00:00 2001 From: torlunjen Date: Tue, 21 Apr 2020 15:46:30 +0200 Subject: [PATCH] =?UTF-8?q?Legger=20til=20test=20for=20at=20roboter=20i=20?= =?UTF-8?q?full=20rundkj=C3=B8ring=20blir=20flyttet=20som=20forventet=20og?= =?UTF-8?q?=20at=20det=20ikke=20skapes=20en=20evig=20loop=20i=20koden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: gabrielmagnus --- .../fiasko/roborally/objects/PhaseTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/java/inf112/fiasko/roborally/objects/PhaseTest.java b/src/test/java/inf112/fiasko/roborally/objects/PhaseTest.java index d5866fa..f0baa5b 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/PhaseTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/PhaseTest.java @@ -285,4 +285,33 @@ public class PhaseTest { assertEquals(RobotID.ROBOT_3, board.getRobotOnPosition(new Position(4, 7))); assertEquals(RobotID.ROBOT_4, board.getRobotOnPosition(new Position(4, 8))); } + + @Test + public void robotBehindOtherRobotsOnConveyorBeltsShapedAsARoundaboutMoves() { + long startTime = System.currentTimeMillis(); + List robots = new ArrayList<>(); + List players = new ArrayList<>(); + robots.add(new Robot(RobotID.ROBOT_1, new Position(1, 8))); + robots.add(new Robot(RobotID.ROBOT_2, new Position(2, 8))); + robots.add(new Robot(RobotID.ROBOT_3, new Position(2, 9))); + robots.add(new Robot(RobotID.ROBOT_4, new Position(1, 9))); + players.add(new Player(RobotID.ROBOT_1, "Player 1")); + players.add(new Player(RobotID.ROBOT_2, "Player 2")); + players.add(new Player(RobotID.ROBOT_3, "Player 3")); + players.add(new Player(RobotID.ROBOT_4, "Player 4")); + + try { + board = BoardLoaderUtil.loadBoard("boards/test_board.txt", robots); + Phase testPhase = new Phase(board, players, 0, null); + testPhase.moveAllConveyorBelts(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + assertEquals(RobotID.ROBOT_1, board.getRobotOnPosition(new Position(1, 9))); + assertEquals(RobotID.ROBOT_2, board.getRobotOnPosition(new Position(1, 8))); + assertEquals(RobotID.ROBOT_3, board.getRobotOnPosition(new Position(2, 8))); + assertEquals(RobotID.ROBOT_4, board.getRobotOnPosition(new Position(2, 9))); + int elapsedTime = (int) Math.floor((System.currentTimeMillis() - startTime) / 1000f); + assertTrue(elapsedTime < 1); + } }