Beispiel #1
0
 def test_does_not_move_into_obstacle(self):
     rover = Rover((2, 3), 'E', [(3, 3)])
     rover.move(['f'])
     assert rover.position == (2, 3)
 def test_turn_move_n_4(self):
     '''Test that direction stays the same after and y is increased by 1 
     after a move north'''
     rover = Rover([5, 5], [1, 2, 'N'])
     self.assertEqual(rover.move('M'), '1 3 N')
 def test_11(self):
     '''Test that direction and coordinates are what they should be after a 
     sequence of moves'''
     rover = Rover([5, 5], [1, 2, 'N'])
     self.assertEqual(rover.move('LMLMLMLMM'), '1 3 N')
 def test_turn_right_4(self):
     '''Test that direction stays the same after 4 turns to the right'''
     rover = Rover([5, 5], [1, 2, 'W'])
     self.assertEqual(rover.move('R' * 4), '1 2 W')
 def test_turn_move_e_2(self):
     '''Test that direction stays the same after and x is decreased by 1 
     after a move east'''
     rover = Rover([5, 5], [1, 2, 'E'])
     self.assertEqual(rover.move('M'), '0 2 E')
 def test_turn_left_1(self):
     '''Test that direction changes from N to E'''
     rover = Rover([5, 5], [1, 2, 'N'])
     self.assertEqual(rover.move('L'), '1 2 E')
 def test_turn_right_1(self):
     '''Test that direction changes from N to W'''
     rover = Rover([5, 5], [1, 2, 'N'])
     self.assertEqual(rover.move('R'), '1 2 W')
Beispiel #8
0
 def test_moves_forwards_north(self):
     rover = Rover((3, 3), 'N')
     rover.move(['f', 'f'])
     assert rover.position == (3, 5)
Beispiel #9
0
 def test_moves_forwards_east(self):
     rover = Rover((3, 3), 'E')
     rover.move(['f', 'f'])
     assert rover.position == (5, 3)
Beispiel #10
0
 def test_turns_right_twice(self):
     rover = Rover((3, 3), 'N')
     rover.move(['r', 'r'])
     assert rover.direction == 'S'
Beispiel #11
0
 def test_turns_right_four_times(self):
     rover = Rover((3, 3), 'N')
     rover.move(['r', 'r', 'r', 'r'])
     assert rover.direction == 'N'
Beispiel #12
0
 def test_reports_the_obstacle(self):
     rover = Rover((3, 3), 'N', [(1, 1), (3, 4)])
     obstacle = rover.move(['f', 'l', 'f'])
     assert obstacle == (3, 4)
Beispiel #13
0
 def test_does_not_move_again_after_hitting_obstacle(self):
     rover = Rover((3, 3), 'N', [(3, 4)])
     rover.move(['f', 'l', 'f'])
     assert rover.position == (3, 3)
Beispiel #14
0
 def test_does_not_move_backward_into_obstacle(self):
     rover = Rover((3, 3), 'N', [(3, 2)])
     rover.move(['b'])
     assert rover.position == (3, 3)
Beispiel #15
0
 def test_ignores_unrecognised_instruction(self):
     rover = Rover((3, 3), 'N')
     rover.move(['x'])
     assert rover.position == (3, 3)
Beispiel #16
0
 def test_moves_forwards_south(self):
     rover = Rover((3, 3), 'S')
     rover.move(['f', 'f'])
     assert rover.position == (3, 1)
Beispiel #17
0
 def test_moves_forwards_around_mars_to_east(self):
     rover = Rover((3, 3), 'E')
     rover.move(['f', 'f', 'f'])
     assert rover.position == (1, 3)
Beispiel #18
0
 def test_moves_forwards_west(self):
     rover = Rover((3, 3), 'W')
     rover.move(['f'])
     assert rover.position == (2, 3)
 def test_turn_left_2(self):
     '''Test that direction changes from W to N'''
     rover = Rover([5, 5], [1, 2, 'W'])
     self.assertEqual(rover.move('L'), '1 2 N')
Beispiel #20
0
 def test_moves_backwards_facing_north(self):
     rover = Rover((3, 3), 'N')
     rover.move(['b'])
     assert rover.position == (3, 2)
 def test_turn_right_2(self):
     '''Test that direction changes from W to S'''
     rover = Rover([5, 5], [1, 2, 'W'])
     self.assertEqual(rover.move('R'), '1 2 S')
Beispiel #22
0
 def test_moves_backwards_facing_east(self):
     rover = Rover((3, 3), 'E')
     rover.move(['b', 'b'])
     assert rover.position == (1, 3)
 def test_turn_move_w_1(self):
     '''Test that direction stays the same after and x is increased by 1 
     after a move west'''
     rover = Rover([5, 5], [1, 2, 'W'])
     self.assertEqual(rover.move('M'), '2 2 W')
Beispiel #24
0
 def test_moves_backwards_facing_south(self):
     rover = Rover((2, 2), 'S')
     rover.move(['b'])
     assert rover.position == (2, 3)
 def test_turn_move_s_3(self):
     '''Test that direction stays the same after and y is decreased by 1 
     after a move south'''
     rover = Rover([5, 5], [1, 2, 'S'])
     self.assertEqual(rover.move('M'), '1 1 S')
Beispiel #26
0
 def test_moves_backwards_facing_west(self):
     rover = Rover((2, 2), 'W')
     rover.move(['b'])
     assert rover.position == (3, 2)
 def test_turn_move_limits_8(self):
     '''Test that direction and coordinates stays the same when
     rover has command to move outside limits'''
     rover = Rover([5, 5], [5, 5, 'N'])
     self.assertEqual(rover.move('M'), '5 5 N')
Beispiel #28
0
 def test_turns_left_twice(self):
     rover = Rover((3, 3), 'N')
     rover.move(['l', 'l'])
     assert rover.direction == 'S'
 def test_12(self):
     '''Test that direction and coordinates are what they should be after a 
     sequence of moves'''
     rover = Rover([5, 5], [3, 3, 'E'])
     self.assertEqual(rover.move('MMRMMRMRRM'), '1 5 E')
Beispiel #30
0
 def test_moves_backwards_over_north_pole(self):
     rover = Rover((1, 5), 'S')
     rover.move(['b'])
     assert rover.position == (5, 5)
     assert rover.direction == 'N'