コード例 #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'