Exemplo n.º 1
0
 def test_initialization_with_params(self):
     rover = MarsRover(1, 1, 1, 2, 3)
     self.assertEqual(rover.angle, 3)
     self.assertEqual(rover.x_pos, 1)
     self.assertEqual(rover.y_pos, 2)
     self.assertEqual(rover.x_length, 1)
     self.assertEqual(rover.y_length, 1)
Exemplo n.º 2
0
 def test_initialization_without_params(self):
     rover = MarsRover()
     self.assertEqual(rover.angle, 0)
     self.assertEqual(rover.x_pos, 0)
     self.assertEqual(rover.y_pos, 0)
     self.assertEqual(rover.x_length, 0)
     self.assertEqual(rover.y_length, 0)
Exemplo n.º 3
0
def run_main():
    coordinates = parser.parse_setup(
        raw_input('Enter top right coordinates:\n'))
    while 1:
        location = parser.parse_location(raw_input('Enter rover location:\n'))
        rover = MarsRover(*(coordinates + location))
        parser.parse_command(raw_input('Enter command:\n'), rover)
        print rover.get_position()
Exemplo n.º 4
0
 def test_turn_right(self):
     rover = MarsRover()
     rover.turn_right()
     self.assertEqual(rover.angle, 3 * pi / 2)
     rover.turn_right()
     self.assertEqual(rover.angle, pi)
     rover.turn_right()
     rover.turn_right()
     self.assertEqual(rover.angle, 0)
Exemplo n.º 5
0
 def test_parse_command(self):
     rover = MarsRover()
     parser.parse_command("m", rover)
     self.assertEqual(rover.get_position(), "1 0 E")
     parser.parse_command("x", rover)
     self.assertEqual(rover.get_position(), "1 0 E")
     parser.parse_command("l", rover)
     self.assertEqual(rover.get_position(), "1 0 N")
     parser.parse_command("r", rover)
     self.assertEqual(rover.get_position(), "1 0 E")
Exemplo n.º 6
0
 def test_get_position(self):
     rover = MarsRover()
     self.assertEqual(rover.get_position(), "0 0 E")
Exemplo n.º 7
0
 def test_turn_angle_more_than_2pi(self):
     rover = MarsRover()
     rover.turn(3 * pi)
     self.assertEqual(rover.angle, pi)
Exemplo n.º 8
0
 def test_turn_angle(self):
     rover = MarsRover()
     rover.turn(5)
     self.assertEqual(rover.angle, 5)
Exemplo n.º 9
0
 def test_move(self):
     rover = MarsRover()
     rover.move()
     self.assertEqual(rover.x_pos, 1)
     self.assertEqual(rover.y_pos, 0)