From d3c7eb9de7310df1795d6f1b17b1aa1eb4e3f0c1 Mon Sep 17 00:00:00 2001 From: fiatcode Date: Tue, 24 Feb 2026 10:56:30 +0700 Subject: [PATCH] chore: format code --- lib/mars_rover.dart | 6 +++--- test/mars_rover_test.dart | 44 ++++++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/lib/mars_rover.dart b/lib/mars_rover.dart index 922267f..221e450 100644 --- a/lib/mars_rover.dart +++ b/lib/mars_rover.dart @@ -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; diff --git a/test/mars_rover_test.dart b/test/mars_rover_test.dart index 90f8f4b..53e4540 100644 --- a/test/mars_rover_test.dart +++ b/test/mars_rover_test.dart @@ -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)); });