|
|
|
|
7
|
|
7
|
|
8
|
@Test
|
8
|
@Test
|
9
|
public void robotIsCreatedWithInitialPositionAndOrientation() {
|
9
|
public void robotIsCreatedWithInitialPositionAndOrientation() {
|
10
|
- final Orientation initialOrientation = Orientation.NORTH;
|
|
|
11
|
- final GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
12
|
- final Robot robot = new Robot(initialGridPosition, initialOrientation);
|
|
|
|
|
10
|
+ Orientation initialOrientation = Orientation.NORTH;
|
|
|
11
|
+ GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
12
|
+ Robot robot = new Robot(initialGridPosition, initialOrientation);
|
13
|
|
13
|
|
14
|
assertEquals(robot.getOrientation(), initialOrientation);
|
14
|
assertEquals(robot.getOrientation(), initialOrientation);
|
15
|
assertEquals(robot.getGridPosition(), initialGridPosition);
|
15
|
assertEquals(robot.getGridPosition(), initialGridPosition);
|
|
|
|
|
18
|
@Ignore("Remove to run test")
|
18
|
@Ignore("Remove to run test")
|
19
|
@Test
|
19
|
@Test
|
20
|
public void testNegativePositionsAreAllowed() {
|
20
|
public void testNegativePositionsAreAllowed() {
|
21
|
- final GridPosition initialGridPosition = new GridPosition(-1, -1);
|
|
|
22
|
- final Orientation initialOrientation = Orientation.SOUTH;
|
|
|
23
|
- final Robot robot = new Robot(initialGridPosition, initialOrientation);
|
|
|
|
|
21
|
+ GridPosition initialGridPosition = new GridPosition(-1, -1);
|
|
|
22
|
+ Orientation initialOrientation = Orientation.SOUTH;
|
|
|
23
|
+ Robot robot = new Robot(initialGridPosition, initialOrientation);
|
24
|
|
24
|
|
25
|
assertEquals(robot.getOrientation(), initialOrientation);
|
25
|
assertEquals(robot.getOrientation(), initialOrientation);
|
26
|
assertEquals(robot.getGridPosition(), initialGridPosition);
|
26
|
assertEquals(robot.getGridPosition(), initialGridPosition);
|
|
|
|
|
29
|
@Ignore("Remove to run test")
|
29
|
@Ignore("Remove to run test")
|
30
|
@Test
|
30
|
@Test
|
31
|
public void testTurningRightDoesNotChangePosition() {
|
31
|
public void testTurningRightDoesNotChangePosition() {
|
32
|
- final GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
33
|
- final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
|
|
|
|
32
|
+ GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
33
|
+ Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
34
|
|
34
|
|
35
|
robot.turnRight();
|
35
|
robot.turnRight();
|
36
|
|
36
|
|
|
|
|
|
40
|
@Ignore("Remove to run test")
|
40
|
@Ignore("Remove to run test")
|
41
|
@Test
|
41
|
@Test
|
42
|
public void testTurningRightCorrectlyChangesOrientationFromNorthToEast() {
|
42
|
public void testTurningRightCorrectlyChangesOrientationFromNorthToEast() {
|
43
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
|
|
|
|
43
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
44
|
|
44
|
|
45
|
robot.turnRight();
|
45
|
robot.turnRight();
|
46
|
|
46
|
|
47
|
- final Orientation expectedOrientation = Orientation.EAST;
|
|
|
|
|
47
|
+ Orientation expectedOrientation = Orientation.EAST;
|
48
|
|
48
|
|
49
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
49
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
50
|
}
|
50
|
}
|
|
|
|
|
52
|
@Ignore("Remove to run test")
|
52
|
@Ignore("Remove to run test")
|
53
|
@Test
|
53
|
@Test
|
54
|
public void testTurningRightCorrectlyChangesOrientationFromEastToSouth() {
|
54
|
public void testTurningRightCorrectlyChangesOrientationFromEastToSouth() {
|
55
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
|
|
|
|
55
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
56
|
|
56
|
|
57
|
robot.turnRight();
|
57
|
robot.turnRight();
|
58
|
|
58
|
|
59
|
- final Orientation expectedOrientation = Orientation.SOUTH;
|
|
|
|
|
59
|
+ Orientation expectedOrientation = Orientation.SOUTH;
|
60
|
|
60
|
|
61
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
61
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
62
|
}
|
62
|
}
|
|
|
|
|
64
|
@Ignore("Remove to run test")
|
64
|
@Ignore("Remove to run test")
|
65
|
@Test
|
65
|
@Test
|
66
|
public void testTurningRightCorrectlyChangesOrientationFromSouthToWest() {
|
66
|
public void testTurningRightCorrectlyChangesOrientationFromSouthToWest() {
|
67
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
|
|
|
|
67
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
68
|
|
68
|
|
69
|
robot.turnRight();
|
69
|
robot.turnRight();
|
70
|
|
70
|
|
71
|
- final Orientation expectedOrientation = Orientation.WEST;
|
|
|
|
|
71
|
+ Orientation expectedOrientation = Orientation.WEST;
|
72
|
|
72
|
|
73
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
73
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
74
|
}
|
74
|
}
|
|
|
|
|
76
|
@Ignore("Remove to run test")
|
76
|
@Ignore("Remove to run test")
|
77
|
@Test
|
77
|
@Test
|
78
|
public void testTurningRightCorrectlyChangesOrientationFromWestToNorth() {
|
78
|
public void testTurningRightCorrectlyChangesOrientationFromWestToNorth() {
|
79
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
|
|
|
|
79
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
80
|
|
80
|
|
81
|
robot.turnRight();
|
81
|
robot.turnRight();
|
82
|
|
82
|
|
83
|
- final Orientation expectedOrientation = Orientation.NORTH;
|
|
|
|
|
83
|
+ Orientation expectedOrientation = Orientation.NORTH;
|
84
|
|
84
|
|
85
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
85
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
86
|
}
|
86
|
}
|
|
|
|
|
88
|
@Ignore("Remove to run test")
|
88
|
@Ignore("Remove to run test")
|
89
|
@Test
|
89
|
@Test
|
90
|
public void testTurningLeftDoesNotChangePosition() {
|
90
|
public void testTurningLeftDoesNotChangePosition() {
|
91
|
- final GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
92
|
- final Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
|
|
|
|
91
|
+ GridPosition initialGridPosition = new GridPosition(0, 0);
|
|
|
92
|
+ Robot robot = new Robot(initialGridPosition, Orientation.NORTH);
|
93
|
|
93
|
|
94
|
robot.turnLeft();
|
94
|
robot.turnLeft();
|
95
|
|
95
|
|
|
|
|
|
99
|
@Ignore("Remove to run test")
|
99
|
@Ignore("Remove to run test")
|
100
|
@Test
|
100
|
@Test
|
101
|
public void testTurningLeftCorrectlyChangesOrientationFromNorthToWest() {
|
101
|
public void testTurningLeftCorrectlyChangesOrientationFromNorthToWest() {
|
102
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
|
|
|
|
102
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
103
|
|
103
|
|
104
|
robot.turnLeft();
|
104
|
robot.turnLeft();
|
105
|
|
105
|
|
106
|
- final Orientation expectedOrientation = Orientation.WEST;
|
|
|
|
|
106
|
+ Orientation expectedOrientation = Orientation.WEST;
|
107
|
|
107
|
|
108
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
108
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
109
|
}
|
109
|
}
|
|
|
|
|
111
|
@Ignore("Remove to run test")
|
111
|
@Ignore("Remove to run test")
|
112
|
@Test
|
112
|
@Test
|
113
|
public void testTurningLeftCorrectlyChangesOrientationFromWestToSouth() {
|
113
|
public void testTurningLeftCorrectlyChangesOrientationFromWestToSouth() {
|
114
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
|
|
|
|
114
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
115
|
|
115
|
|
116
|
robot.turnLeft();
|
116
|
robot.turnLeft();
|
117
|
|
117
|
|
118
|
- final Orientation expectedOrientation = Orientation.SOUTH;
|
|
|
|
|
118
|
+ Orientation expectedOrientation = Orientation.SOUTH;
|
119
|
|
119
|
|
120
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
120
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
121
|
}
|
121
|
}
|
|
|
|
|
123
|
@Ignore("Remove to run test")
|
123
|
@Ignore("Remove to run test")
|
124
|
@Test
|
124
|
@Test
|
125
|
public void testTurningLeftCorrectlyChangesOrientationFromSouthToEast() {
|
125
|
public void testTurningLeftCorrectlyChangesOrientationFromSouthToEast() {
|
126
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
|
|
|
|
126
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
127
|
|
127
|
|
128
|
robot.turnLeft();
|
128
|
robot.turnLeft();
|
129
|
|
129
|
|
130
|
- final Orientation expectedOrientation = Orientation.EAST;
|
|
|
|
|
130
|
+ Orientation expectedOrientation = Orientation.EAST;
|
131
|
|
131
|
|
132
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
132
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
133
|
}
|
133
|
}
|
|
|
|
|
135
|
@Ignore("Remove to run test")
|
135
|
@Ignore("Remove to run test")
|
136
|
@Test
|
136
|
@Test
|
137
|
public void testTurningLeftCorrectlyChangesOrientationFromEastToNorth() {
|
137
|
public void testTurningLeftCorrectlyChangesOrientationFromEastToNorth() {
|
138
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
|
|
|
|
138
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
139
|
|
139
|
|
140
|
robot.turnLeft();
|
140
|
robot.turnLeft();
|
141
|
|
141
|
|
142
|
- final Orientation expectedOrientation = Orientation.NORTH;
|
|
|
|
|
142
|
+ Orientation expectedOrientation = Orientation.NORTH;
|
143
|
|
143
|
|
144
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
144
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
145
|
}
|
145
|
}
|
|
|
|
|
147
|
@Ignore("Remove to run test")
|
147
|
@Ignore("Remove to run test")
|
148
|
@Test
|
148
|
@Test
|
149
|
public void testAdvancingDoesNotChangeOrientation() {
|
149
|
public void testAdvancingDoesNotChangeOrientation() {
|
150
|
- final Orientation initialOrientation = Orientation.NORTH;
|
|
|
151
|
- final Robot robot = new Robot(new GridPosition(0, 0), initialOrientation);
|
|
|
|
|
150
|
+ Orientation initialOrientation = Orientation.NORTH;
|
|
|
151
|
+ Robot robot = new Robot(new GridPosition(0, 0), initialOrientation);
|
152
|
|
152
|
|
153
|
robot.advance();
|
153
|
robot.advance();
|
154
|
|
154
|
|
|
|
|
|
158
|
@Ignore("Remove to run test")
|
158
|
@Ignore("Remove to run test")
|
159
|
@Test
|
159
|
@Test
|
160
|
public void testAdvancingWhenFacingNorthIncreasesYCoordinateByOne() {
|
160
|
public void testAdvancingWhenFacingNorthIncreasesYCoordinateByOne() {
|
161
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
|
|
|
|
161
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
162
|
|
162
|
|
163
|
robot.advance();
|
163
|
robot.advance();
|
164
|
|
164
|
|
165
|
- final GridPosition expectedGridPosition = new GridPosition(0, 1);
|
|
|
|
|
165
|
+ GridPosition expectedGridPosition = new GridPosition(0, 1);
|
166
|
|
166
|
|
167
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
167
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
168
|
}
|
168
|
}
|
|
|
|
|
170
|
@Ignore("Remove to run test")
|
170
|
@Ignore("Remove to run test")
|
171
|
@Test
|
171
|
@Test
|
172
|
public void testAdvancingWhenFacingSouthDecreasesYCoordinateByOne() {
|
172
|
public void testAdvancingWhenFacingSouthDecreasesYCoordinateByOne() {
|
173
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
|
|
|
|
173
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.SOUTH);
|
174
|
|
174
|
|
175
|
robot.advance();
|
175
|
robot.advance();
|
176
|
|
176
|
|
177
|
- final GridPosition expectedGridPosition = new GridPosition(0, -1);
|
|
|
|
|
177
|
+ GridPosition expectedGridPosition = new GridPosition(0, -1);
|
178
|
|
178
|
|
179
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
179
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
180
|
}
|
180
|
}
|
|
|
|
|
182
|
@Ignore("Remove to run test")
|
182
|
@Ignore("Remove to run test")
|
183
|
@Test
|
183
|
@Test
|
184
|
public void testAdvancingWhenFacingEastIncreasesXCoordinateByOne() {
|
184
|
public void testAdvancingWhenFacingEastIncreasesXCoordinateByOne() {
|
185
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
|
|
|
|
185
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.EAST);
|
186
|
|
186
|
|
187
|
robot.advance();
|
187
|
robot.advance();
|
188
|
|
188
|
|
189
|
- final GridPosition expectedGridPosition = new GridPosition(1, 0);
|
|
|
|
|
189
|
+ GridPosition expectedGridPosition = new GridPosition(1, 0);
|
190
|
|
190
|
|
191
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
191
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
192
|
}
|
192
|
}
|
|
|
|
|
194
|
@Ignore("Remove to run test")
|
194
|
@Ignore("Remove to run test")
|
195
|
@Test
|
195
|
@Test
|
196
|
public void testAdvancingWhenFacingWestDecreasesXCoordinateByOne() {
|
196
|
public void testAdvancingWhenFacingWestDecreasesXCoordinateByOne() {
|
197
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
|
|
|
|
197
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.WEST);
|
198
|
|
198
|
|
199
|
robot.advance();
|
199
|
robot.advance();
|
200
|
|
200
|
|
201
|
- final GridPosition expectedGridPosition = new GridPosition(-1, 0);
|
|
|
|
|
201
|
+ GridPosition expectedGridPosition = new GridPosition(-1, 0);
|
202
|
|
202
|
|
203
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
203
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
204
|
}
|
204
|
}
|
|
|
|
|
206
|
@Ignore("Remove to run test")
|
206
|
@Ignore("Remove to run test")
|
207
|
@Test
|
207
|
@Test
|
208
|
public void testInstructionsToMoveWestAndNorth() {
|
208
|
public void testInstructionsToMoveWestAndNorth() {
|
209
|
- final Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
|
|
|
|
209
|
+ Robot robot = new Robot(new GridPosition(0, 0), Orientation.NORTH);
|
210
|
|
210
|
|
211
|
robot.simulate("LAAARALA");
|
211
|
robot.simulate("LAAARALA");
|
212
|
|
212
|
|
213
|
- final GridPosition expectedGridPosition = new GridPosition(-4, 1);
|
|
|
214
|
- final Orientation expectedOrientation = Orientation.WEST;
|
|
|
|
|
213
|
+ GridPosition expectedGridPosition = new GridPosition(-4, 1);
|
|
|
214
|
+ Orientation expectedOrientation = Orientation.WEST;
|
215
|
|
215
|
|
216
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
216
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
217
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
217
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
|
|
|
|
220
|
@Ignore("Remove to run test")
|
220
|
@Ignore("Remove to run test")
|
221
|
@Test
|
221
|
@Test
|
222
|
public void testInstructionsToMoveWestAndSouth() {
|
222
|
public void testInstructionsToMoveWestAndSouth() {
|
223
|
- final Robot robot = new Robot(new GridPosition(2, -7), Orientation.EAST);
|
|
|
|
|
223
|
+ Robot robot = new Robot(new GridPosition(2, -7), Orientation.EAST);
|
224
|
|
224
|
|
225
|
robot.simulate("RRAAAAALA");
|
225
|
robot.simulate("RRAAAAALA");
|
226
|
|
226
|
|
227
|
- final GridPosition expectedGridPosition = new GridPosition(-3, -8);
|
|
|
228
|
- final Orientation expectedOrientation = Orientation.SOUTH;
|
|
|
|
|
227
|
+ GridPosition expectedGridPosition = new GridPosition(-3, -8);
|
|
|
228
|
+ Orientation expectedOrientation = Orientation.SOUTH;
|
229
|
|
229
|
|
230
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
230
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
231
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
231
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
|
|
|
|
234
|
@Ignore("Remove to run test")
|
234
|
@Ignore("Remove to run test")
|
235
|
@Test
|
235
|
@Test
|
236
|
public void testInstructionsToMoveEastAndNorth() {
|
236
|
public void testInstructionsToMoveEastAndNorth() {
|
237
|
- final Robot robot = new Robot(new GridPosition(8, 4), Orientation.SOUTH);
|
|
|
|
|
237
|
+ Robot robot = new Robot(new GridPosition(8, 4), Orientation.SOUTH);
|
238
|
|
238
|
|
239
|
robot.simulate("LAAARRRALLLL");
|
239
|
robot.simulate("LAAARRRALLLL");
|
240
|
|
240
|
|
241
|
- final GridPosition expectedGridPosition = new GridPosition(11, 5);
|
|
|
242
|
- final Orientation expectedOrientation = Orientation.NORTH;
|
|
|
|
|
241
|
+ GridPosition expectedGridPosition = new GridPosition(11, 5);
|
|
|
242
|
+ Orientation expectedOrientation = Orientation.NORTH;
|
243
|
|
243
|
|
244
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
244
|
assertEquals(robot.getGridPosition(), expectedGridPosition);
|
245
|
assertEquals(robot.getOrientation(), expectedOrientation);
|
245
|
assertEquals(robot.getOrientation(), expectedOrientation);
|