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