RED: test plateau boundaries with wrapping
This commit is contained in:
parent
e292e66c64
commit
1078e1947e
1 changed files with 32 additions and 0 deletions
|
|
@ -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));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue