chore: format code
This commit is contained in:
parent
e5a651951d
commit
d3c7eb9de7
2 changed files with 40 additions and 10 deletions
|
|
@ -61,9 +61,9 @@ class Rover {
|
||||||
required String direction,
|
required String direction,
|
||||||
int plateauWidth = 100,
|
int plateauWidth = 100,
|
||||||
int plateauHeight = 100,
|
int plateauHeight = 100,
|
||||||
}) : _position = Position(x, y),
|
}) : _position = Position(x, y),
|
||||||
_direction = Direction.fromCode(direction),
|
_direction = Direction.fromCode(direction),
|
||||||
plateau = Plateau(plateauWidth, plateauHeight);
|
plateau = Plateau(plateauWidth, plateauHeight);
|
||||||
|
|
||||||
int get x => _position.x;
|
int get x => _position.x;
|
||||||
int get y => _position.y;
|
int get y => _position.y;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:test/test.dart';
|
|
||||||
import 'package:tdd_katas/mars_rover.dart';
|
import 'package:tdd_katas/mars_rover.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Mars Rover:', () {
|
group('Mars Rover:', () {
|
||||||
|
|
@ -131,31 +131,61 @@ void main() {
|
||||||
|
|
||||||
group('Plateau Boundaries:', () {
|
group('Plateau Boundaries:', () {
|
||||||
test('wraps around when moving North past boundary', () {
|
test('wraps around when moving North past boundary', () {
|
||||||
final rover = Rover(x: 0, y: 5, direction: 'N', plateauWidth: 5, plateauHeight: 5);
|
final rover = Rover(
|
||||||
|
x: 0,
|
||||||
|
y: 5,
|
||||||
|
direction: 'N',
|
||||||
|
plateauWidth: 5,
|
||||||
|
plateauHeight: 5,
|
||||||
|
);
|
||||||
rover.moveForward();
|
rover.moveForward();
|
||||||
expect(rover.y, equals(0));
|
expect(rover.y, equals(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('wraps around when moving East past boundary', () {
|
test('wraps around when moving East past boundary', () {
|
||||||
final rover = Rover(x: 5, y: 0, direction: 'E', plateauWidth: 5, plateauHeight: 5);
|
final rover = Rover(
|
||||||
|
x: 5,
|
||||||
|
y: 0,
|
||||||
|
direction: 'E',
|
||||||
|
plateauWidth: 5,
|
||||||
|
plateauHeight: 5,
|
||||||
|
);
|
||||||
rover.moveForward();
|
rover.moveForward();
|
||||||
expect(rover.x, equals(0));
|
expect(rover.x, equals(0));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('wraps around when moving South past boundary', () {
|
test('wraps around when moving South past boundary', () {
|
||||||
final rover = Rover(x: 0, y: 0, direction: 'S', plateauWidth: 5, plateauHeight: 5);
|
final rover = Rover(
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
direction: 'S',
|
||||||
|
plateauWidth: 5,
|
||||||
|
plateauHeight: 5,
|
||||||
|
);
|
||||||
rover.moveForward();
|
rover.moveForward();
|
||||||
expect(rover.y, equals(5));
|
expect(rover.y, equals(5));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('wraps around when moving West past boundary', () {
|
test('wraps around when moving West past boundary', () {
|
||||||
final rover = Rover(x: 0, y: 0, direction: 'W', plateauWidth: 5, plateauHeight: 5);
|
final rover = Rover(
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
direction: 'W',
|
||||||
|
plateauWidth: 5,
|
||||||
|
plateauHeight: 5,
|
||||||
|
);
|
||||||
rover.moveForward();
|
rover.moveForward();
|
||||||
expect(rover.x, equals(5));
|
expect(rover.x, equals(5));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('example with wrapping', () {
|
test('example with wrapping', () {
|
||||||
final rover = Rover(x: 5, y: 5, direction: 'N', plateauWidth: 5, plateauHeight: 5);
|
final rover = Rover(
|
||||||
|
x: 5,
|
||||||
|
y: 5,
|
||||||
|
direction: 'N',
|
||||||
|
plateauWidth: 5,
|
||||||
|
plateauHeight: 5,
|
||||||
|
);
|
||||||
rover.execute('MMM');
|
rover.execute('MMM');
|
||||||
expect(rover.y, equals(2));
|
expect(rover.y, equals(2));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue