Exemplo n.º 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)
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
 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')
Exemplo n.º 5
0
 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')
Exemplo n.º 6
0
 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')
Exemplo n.º 7
0
 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')
Exemplo n.º 8
0
 def test_moves_forwards_north(self):
     rover = Rover((3, 3), 'N')
     rover.move(['f', 'f'])
     assert rover.position == (3, 5)
Exemplo n.º 9
0
 def test_moves_forwards_east(self):
     rover = Rover((3, 3), 'E')
     rover.move(['f', 'f'])
     assert rover.position == (5, 3)
Exemplo n.º 10
0
 def test_turns_right_twice(self):
     rover = Rover((3, 3), 'N')
     rover.move(['r', 'r'])
     assert rover.direction == 'S'
Exemplo n.º 11
0
 def test_turns_right_four_times(self):
     rover = Rover((3, 3), 'N')
     rover.move(['r', 'r', 'r', 'r'])
     assert rover.direction == 'N'
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 15
0
 def test_ignores_unrecognised_instruction(self):
     rover = Rover((3, 3), 'N')
     rover.move(['x'])
     assert rover.position == (3, 3)
Exemplo n.º 16
0
 def test_moves_forwards_south(self):
     rover = Rover((3, 3), 'S')
     rover.move(['f', 'f'])
     assert rover.position == (3, 1)
Exemplo n.º 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)
Exemplo n.º 18
0
 def test_moves_forwards_west(self):
     rover = Rover((3, 3), 'W')
     rover.move(['f'])
     assert rover.position == (2, 3)
Exemplo n.º 19
0
 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')
Exemplo n.º 20
0
 def test_moves_backwards_facing_north(self):
     rover = Rover((3, 3), 'N')
     rover.move(['b'])
     assert rover.position == (3, 2)
Exemplo n.º 21
0
 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')
Exemplo n.º 22
0
 def test_moves_backwards_facing_east(self):
     rover = Rover((3, 3), 'E')
     rover.move(['b', 'b'])
     assert rover.position == (1, 3)
Exemplo n.º 23
0
 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')
Exemplo n.º 24
0
 def test_moves_backwards_facing_south(self):
     rover = Rover((2, 2), 'S')
     rover.move(['b'])
     assert rover.position == (2, 3)
Exemplo n.º 25
0
 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')
Exemplo n.º 26
0
 def test_moves_backwards_facing_west(self):
     rover = Rover((2, 2), 'W')
     rover.move(['b'])
     assert rover.position == (3, 2)
Exemplo n.º 27
0
 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')
Exemplo n.º 28
0
 def test_turns_left_twice(self):
     rover = Rover((3, 3), 'N')
     rover.move(['l', 'l'])
     assert rover.direction == 'S'
Exemplo n.º 29
0
 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')
Exemplo n.º 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'