prepare failing test for the planet loop requirement
This commit is contained in:
parent
72ca8a2629
commit
b1ecef985b
|
@ -58,4 +58,8 @@ public class Coordinates {
|
|||
", longitude=" + longitude +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Coordinates copy() {
|
||||
return new Coordinates(latitude, longitude);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MarsRover {
|
|||
}
|
||||
|
||||
public Coordinates getCurrentCoordinates() {
|
||||
return currentCoordinates;
|
||||
return currentCoordinates.copy();
|
||||
}
|
||||
|
||||
public MarsMap.Direction getCurrentDirection() {
|
||||
|
|
|
@ -28,13 +28,23 @@ public class MarsRoverTest {
|
|||
|
||||
@Test
|
||||
public void stepForward() {
|
||||
Coordinates currentPosition = rover.moveForward();
|
||||
assertEquals(currentPosition, Coordinates.of(3, 3));
|
||||
assertEquals(rover.getCurrentDirection(), SOUTH);
|
||||
Direction originalDirection = rover.getCurrentDirection();
|
||||
|
||||
repeatAction(5, i -> rover.moveForward());
|
||||
assertEquals(rover.getCurrentCoordinates(), Coordinates.of(8, 3));
|
||||
assertEquals(rover.getCurrentDirection(), SOUTH);
|
||||
Coordinates oneStepForward = rover.moveForward();
|
||||
|
||||
assertEquals(oneStepForward, Coordinates.of(3, 3));
|
||||
assertEquals(rover.getCurrentDirection(), originalDirection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loopTheWorldMovingForward() {
|
||||
Coordinates originalCoordinates = rover.getCurrentCoordinates();
|
||||
Direction originalDirection = rover.getCurrentDirection();
|
||||
|
||||
repeatAction(10, i -> rover.moveForward());
|
||||
|
||||
assertEquals(rover.getCurrentCoordinates(), originalCoordinates);
|
||||
assertEquals(rover.getCurrentDirection(), originalDirection);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue