From 911358f2a2e5fa36e8e8092b95f02149c3bf2426 Mon Sep 17 00:00:00 2001 From: Xavier Fontanet Date: Thu, 20 Jun 2024 21:54:56 +0200 Subject: [PATCH] another loop on longitude but moving backwards --- .../codingtests/marsrover/MarsRoverTest.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/java/cat/hack3/codingtests/marsrover/MarsRoverTest.java b/src/test/java/cat/hack3/codingtests/marsrover/MarsRoverTest.java index 2f10333..80c6192 100644 --- a/src/test/java/cat/hack3/codingtests/marsrover/MarsRoverTest.java +++ b/src/test/java/cat/hack3/codingtests/marsrover/MarsRoverTest.java @@ -35,7 +35,7 @@ public class MarsRoverTest { } @Test - public void loopTheWorldMovingForward() { + public void loopTheWorldInLatitudeMovingForward() { Coordinates originalCoordinates = rover.getCurrentCoordinates(); Direction originalDirection = rover.getCurrentDirection(); @@ -47,9 +47,23 @@ public class MarsRoverTest { @Test public void stepBackwards() { + Direction originalDirection = rover.getCurrentDirection(); + Coordinates currentPosition = rover.moveBackwards(); + assertEquals(currentPosition, Coordinates.of(1, 3)); - assertEquals(rover.getCurrentDirection(), SOUTH); + assertEquals(rover.getCurrentDirection(), originalDirection); + } + + @Test + public void loopTheWorldInLatitudeMovingBackwards() { + Coordinates originalCoordinates = rover.getCurrentCoordinates(); + Direction originalDirection = rover.getCurrentDirection(); + + repeatAction(10, i -> rover.moveBackwards()); + + assertEquals(rover.getCurrentCoordinates(), originalCoordinates); + assertEquals(rover.getCurrentDirection(), originalDirection); } @Test