RED: test plateau boundaries with wrapping

This commit is contained in:
fiatcode 2026-02-24 10:49:06 +07:00
parent e292e66c64
commit 1078e1947e

View file

@ -128,5 +128,37 @@ void main() {
expect(rover.direction, equals('N')); 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));
});
});
}); });
} }