diff --git a/test/mars_rover_test.dart b/test/mars_rover_test.dart index 1c23070..90f8f4b 100644 --- a/test/mars_rover_test.dart +++ b/test/mars_rover_test.dart @@ -128,5 +128,37 @@ void main() { expect(rover.direction, equals('N')); }); }); + + group('Plateau Boundaries:', () { + test('wraps around when moving North past boundary', () { + final rover = Rover(x: 0, y: 5, direction: 'N', plateauWidth: 5, plateauHeight: 5); + rover.moveForward(); + expect(rover.y, equals(0)); + }); + + test('wraps around when moving East past boundary', () { + final rover = Rover(x: 5, y: 0, direction: 'E', plateauWidth: 5, plateauHeight: 5); + rover.moveForward(); + expect(rover.x, equals(0)); + }); + + test('wraps around when moving South past boundary', () { + final rover = Rover(x: 0, y: 0, direction: 'S', plateauWidth: 5, plateauHeight: 5); + rover.moveForward(); + expect(rover.y, equals(5)); + }); + + test('wraps around when moving West past boundary', () { + final rover = Rover(x: 0, y: 0, direction: 'W', plateauWidth: 5, plateauHeight: 5); + rover.moveForward(); + expect(rover.x, equals(5)); + }); + + test('example with wrapping', () { + final rover = Rover(x: 5, y: 5, direction: 'N', plateauWidth: 5, plateauHeight: 5); + rover.execute('MMM'); + expect(rover.y, equals(2)); + }); + }); }); }