Ejemplo n.º 1
0
 def test_rotate_turn_left(self):
     dirA = [EAST, SOUTH, WEST, NORTH]
     dirB = [NORTH, EAST, SOUTH, WEST]
     for x in range(len(dirA)):
         robot = Robot(dirA[x], 0, 0)
         robot.turn_left()
         self.assertEqual(robot.bearing, dirB[x])
Ejemplo n.º 2
0
 def test_rotate_simulate_L(self):
     A = [NORTH, WEST, SOUTH, EAST]
     B = [WEST, SOUTH, EAST, NORTH]
     for x in range(len(A)):
         robot = Robot(A[x], 0, 0)
         robot.simulate("L")
         self.assertEqual(robot.bearing, B[x])
Ejemplo n.º 3
0
 def test_turn_left(self):
     dirA = [EAST, SOUTH, WEST, NORTH]
     dirB = [NORTH, EAST, SOUTH, WEST]
     for x in range(len(dirA)):
         robot = Robot(dirA[x], 0, 0)
         robot.turn_left()
         self.assertEqual(robot.bearing, dirB[x])
 def test_rotate_simulate_R(self):
     A = [NORTH, EAST, SOUTH, WEST]
     B = [EAST, SOUTH, WEST, NORTH]
     for x in range(len(A)):
         robot = Robot(A[x], 0, 0)
         robot.simulate("R")
         self.assertEqual(robot.bearing, B[x])
Ejemplo n.º 5
0
 def test_rotating_counter_clockwise_by_simulate_L(self):
     A = [NORTH, WEST, SOUTH, EAST]
     B = [WEST, SOUTH, EAST, NORTH]
     for x in range(len(A)):
         robot = Robot(A[x], 0, 0)
         robot.simulate("L")
         self.assertEqual(robot.bearing, B[x])
Ejemplo n.º 6
0
 def test_change_direction_left(self):
     A = [NORTH, WEST, SOUTH, EAST]
     B = [WEST, SOUTH, EAST, NORTH]
     for x in range(len(A)):
         robot = Robot(A[x], 0, 0)
         robot.simulate("L")
         self.assertEqual(robot.bearing, B[x])
Ejemplo n.º 7
0
 def test_rotating_counter_clockwise(self):
     dirA = [NORTH, EAST, SOUTH, WEST]
     dirB = [WEST, NORTH, EAST, SOUTH]
     for x in range(len(dirA)):
         robot = Robot(dirA[x], 0, 0)
         robot.turn_left()
         self.assertEqual(robot.bearing, dirB[x])
 def test_init(self):
     robot = Robot()  # instaniate robot w/o passing in arguments
     self.assertEqual((0, 0), robot.coordinates
                      )  # robot.coordinates attribute should return (0,0)
     self.assertEqual(
         NORTH,
         robot.bearing)  # robot.bearing attribute should return NORTH
 def test_setup(self):
     robot = Robot(SOUTH, -1,
                   1)  # instaniate robot with passing in arguments
     self.assertEqual((-1, 1), robot.coordinates
                      )  # robot.coordinates attribute should return (-1,1)
     self.assertEqual(
         SOUTH,
         robot.bearing)  # robot.bearing attribute should return SOUTH
Ejemplo n.º 10
0
    def test_at_negative_position_facing_south(self):
        robot = Robot(SOUTH, -1, -1)

        self.assertEqual(robot.coordinates, (-1, -1))
        self.assertEqual(robot.direction, SOUTH)
Ejemplo n.º 11
0
    def test_moving_west_and_south(self):
        robot = Robot(EAST, 2, -7)
        robot.move("RRAAAAALA")

        self.assertEqual(robot.coordinates, (-3, -8))
        self.assertEqual(robot.direction, SOUTH)
Ejemplo n.º 12
0
    def test_moving_east_and_north_from_readme(self):
        robot = Robot(NORTH, 7, 3)
        robot.move("RAALAL")

        self.assertEqual(robot.coordinates, (9, 4))
        self.assertEqual(robot.direction, WEST)
Ejemplo n.º 13
0
    def test_at_origin_facing_north(self):
        robot = Robot(NORTH, 0, 0)

        self.assertEqual(robot.coordinates, (0, 0))
        self.assertEqual(robot.direction, NORTH)
Ejemplo n.º 14
0
 def test_simulate_prog3(self):
     robot = Robot(SOUTH, 8, 4)
     robot.simulate("LAAARRRALLLL")
     self.assertEqual(robot.coordinates, (11, 5))
     self.assertEqual(robot.bearing, NORTH)
Ejemplo n.º 15
0
    def test_facing_south_decrements_y(self):
        robot = Robot(SOUTH, 0, 0)
        robot.move("A")

        self.assertEqual(robot.coordinates, (0, -1))
        self.assertEqual(robot.direction, SOUTH)
Ejemplo n.º 16
0
 def test_advance_positive_west(self):
     robot = Robot(WEST, 0, 0)
     robot.advance()
     self.assertEqual((-1, 0), robot.coordinates)
     self.assertEqual(WEST, robot.bearing)
Ejemplo n.º 17
0
    def test_changes_west_to_south(self):
        robot = Robot(WEST, 0, 0)
        robot.move("L")

        self.assertEqual(robot.coordinates, (0, 0))
        self.assertEqual(robot.direction, SOUTH)
Ejemplo n.º 18
0
 def test_advance_positive_east(self):
     robot = Robot(EAST, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (1, 0))
     self.assertEqual(robot.bearing, EAST)
Ejemplo n.º 19
0
    def test_changes_east_to_north(self):
        robot = Robot(EAST, 0, 0)
        robot.move("L")

        self.assertEqual(robot.coordinates, (0, 0))
        self.assertEqual(robot.direction, NORTH)
Ejemplo n.º 20
0
 def test_simulate_prog1(self):
     robot = Robot(NORTH, 0, 0)
     robot.simulate("LAAARALA")
     self.assertEqual(robot.coordinates, (-4, 1))
     self.assertEqual(robot.bearing, WEST)
Ejemplo n.º 21
0
 def test_turn_left(self):
     robot = Robot()
     for direction in [WEST, SOUTH, EAST, NORTH]:
         robot.turn_left()
         self.assertEqual(robot.bearing, direction)
Ejemplo n.º 22
0
 def test_move_east_north_from_README(self):
     robot = Robot(NORTH, 7, 3)
     robot.simulate("RAALAL")
     self.assertEqual(robot.coordinates, (9, 4))
     self.assertEqual(robot.bearing, WEST)
Ejemplo n.º 23
0
 def test_advance_negative_west(self):
     robot = Robot(WEST, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (-1, 0))
     self.assertEqual(robot.bearing, WEST)
Ejemplo n.º 24
0
 def test_advance_positive_north(self):
     robot = Robot(NORTH, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (0, 1))
     self.assertEqual(robot.bearing, NORTH)
Ejemplo n.º 25
0
 def test_simulate_prog2(self):
     robot = Robot(EAST, 2, -7)
     robot.simulate("RRAAAAALA")
     self.assertEqual(robot.coordinates, (-3, -8))
     self.assertEqual(robot.bearing, SOUTH)
Ejemplo n.º 26
0
 def test_advance_negative_south(self):
     robot = Robot(SOUTH, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (0, -1))
     self.assertEqual(robot.bearing, SOUTH)
Ejemplo n.º 27
0
 def test_init(self):
     robot = Robot()
     self.assertEqual(robot.coordinates, (0, 0))
     self.assertEqual(robot.bearing, NORTH)
Ejemplo n.º 28
0
 def test_advance_positive_east(self):
     robot = Robot(EAST, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (1, 0))
     self.assertEqual(robot.bearing, EAST)
Ejemplo n.º 29
0
    def test_facing_west_decrements_x(self):
        robot = Robot(WEST, 0, 0)
        robot.move("A")

        self.assertEqual(robot.coordinates, (-1, 0))
        self.assertEqual(robot.direction, WEST)
Ejemplo n.º 30
0
 def test_advance_negative_west(self):
     robot = Robot(WEST, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (-1, 0))
     self.assertEqual(robot.bearing, WEST)
Ejemplo n.º 31
0
    def test_moving_west_and_north(self):
        robot = Robot(NORTH, 0, 0)
        robot.move("LAAARALA")

        self.assertEqual(robot.coordinates, (-4, 1))
        self.assertEqual(robot.direction, WEST)
Ejemplo n.º 32
0
 def test_simulate_prog1(self):
     robot = Robot(NORTH, 0, 0)
     robot.simulate("LAAARALA")
     self.assertEqual(robot.coordinates, (-4, 1))
     self.assertEqual(robot.bearing, WEST)
Ejemplo n.º 33
0
    def test_moving_east_and_north(self):
        robot = Robot(SOUTH, 8, 4)
        robot.move("LAAARRRALLLL")

        self.assertEqual(robot.coordinates, (11, 5))
        self.assertEqual(robot.direction, NORTH)
Ejemplo n.º 34
0
 def test_simulate_prog2(self):
     robot = Robot(EAST, 2, -7)
     robot.simulate("RRAAAAALA")
     self.assertEqual(robot.coordinates, (-3, -8))
     self.assertEqual(robot.bearing, SOUTH)
Ejemplo n.º 35
0
    def test_changes_north_to_west(self):
        robot = Robot(NORTH, 0, 0)
        robot.move("L")

        self.assertEqual(robot.coordinates, (0, 0))
        self.assertEqual(robot.direction, WEST)
Ejemplo n.º 36
0
 def test_simulate_prog3(self):
     robot = Robot(SOUTH, 8, 4)
     robot.simulate("LAAARRRALLLL")
     self.assertEqual(robot.coordinates, (11, 5))
     self.assertEqual(robot.bearing, NORTH)
Ejemplo n.º 37
0
    def test_changes_south_to_east(self):
        robot = Robot(SOUTH, 0, 0)
        robot.move("L")

        self.assertEqual(robot.coordinates, (0, 0))
        self.assertEqual(robot.direction, EAST)
Ejemplo n.º 38
0
 def test_turn_left(self):
     robot = Robot()
     for direction in [WEST, SOUTH, EAST, NORTH]:
         robot.turn_left()
         self.assertEqual(robot.bearing, direction)
Ejemplo n.º 39
0
    def test_facing_north_increments_y(self):
        robot = Robot(NORTH, 0, 0)
        robot.move("A")

        self.assertEqual(robot.coordinates, (0, 1))
        self.assertEqual(robot.direction, NORTH)
Ejemplo n.º 40
0
 def test_advance_positive_north(self):
     robot = Robot(NORTH, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (0, 1))
     self.assertEqual(robot.bearing, NORTH)
Ejemplo n.º 41
0
    def test_facing_east_increments_x(self):
        robot = Robot(EAST, 0, 0)
        robot.move("A")

        self.assertEqual(robot.coordinates, (1, 0))
        self.assertEqual(robot.direction, EAST)
Ejemplo n.º 42
0
 def test_advance_negative_south(self):
     robot = Robot(SOUTH, 0, 0)
     robot.advance()
     self.assertEqual(robot.coordinates, (0, -1))
     self.assertEqual(robot.bearing, SOUTH)