chore: format code

This commit is contained in:
fiatcode 2026-02-24 10:56:30 +07:00
parent e5a651951d
commit d3c7eb9de7
2 changed files with 40 additions and 10 deletions

View file

@ -61,9 +61,9 @@ class Rover {
required String direction,
int plateauWidth = 100,
int plateauHeight = 100,
}) : _position = Position(x, y),
_direction = Direction.fromCode(direction),
plateau = Plateau(plateauWidth, plateauHeight);
}) : _position = Position(x, y),
_direction = Direction.fromCode(direction),
plateau = Plateau(plateauWidth, plateauHeight);
int get x => _position.x;
int get y => _position.y;

View file

@ -1,11 +1,11 @@
import 'package:test/test.dart';
import 'package:tdd_katas/mars_rover.dart';
import 'package:test/test.dart';
void main() {
group('Mars Rover:', () {
test('rover reports initial position and direction', () {
final rover = Rover(x: 0, y: 0, direction: 'N');
expect(rover.x, equals(0));
expect(rover.y, equals(0));
expect(rover.direction, equals('N'));
@ -131,31 +131,61 @@ void main() {
group('Plateau Boundaries:', () {
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();
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);
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);
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);
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);
final rover = Rover(
x: 5,
y: 5,
direction: 'N',
plateauWidth: 5,
plateauHeight: 5,
);
rover.execute('MMM');
expect(rover.y, equals(2));
});