From 1078e1947e4e9c4779e230d07931a997cb565691 Mon Sep 17 00:00:00 2001 From: fiatcode Date: Tue, 24 Feb 2026 10:49:06 +0700 Subject: [PATCH] RED: test plateau boundaries with wrapping --- test/mars_rover_test.dart | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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)); + }); + }); }); }