Exemplo n.º 1
0
def test_scenario_3():
    robot = robot_sim.Robot()
    robot.input_parser("PLACE 1,2,EAST")
    robot.input_parser("MOVE")
    robot.input_parser("MOVE")
    robot.input_parser("LEFT")
    robot.input_parser("MOVE")
    assert robot.input_parser("REPORT") == (3, 3, "NORTH")
Exemplo n.º 2
0
def test_scenario_2():
    robot = robot_sim.Robot()
    robot.input_parser("PLACE 0,0,NORTH")
    robot.input_parser("LEFT")
    assert robot.input_parser("REPORT") == (0, 0, "WEST")
Exemplo n.º 3
0
def test_scenario_1():
    robot = robot_sim.Robot()
    robot.input_parser("PLACE 0,0,NORTH")
    robot.input_parser("MOVE")
    assert robot.input_parser("REPORT") == (0, 1, "NORTH")
Exemplo n.º 4
0
def test_multi_place():
    robot = robot_sim.Robot()
    robot.place(3, 3, "east")
    robot.place(4, 2, "north")
    robot.place(2, 1, "bad orientation")
    assert (robot.x_pos, robot.y_pos, robot.orientation) == (4, 2, "north")
Exemplo n.º 5
0
def test_off_grid(x, y, orientation):
    robot = robot_sim.Robot()
    robot.place(x, y, orientation)
    assert robot.move() == "Sorry, don't want to fall off!"
Exemplo n.º 6
0
def test_bad_commands(bad_command):
    robot = robot_sim.Robot()
    assert robot.input_parser(bad_command) == "Oops, try again"
Exemplo n.º 7
0
def test_invalid_pos(x, y):
    robot = robot_sim.Robot()
    assert robot.validate(x, y) is False
Exemplo n.º 8
0
def test_right(starting, expected):
    robot = robot_sim.Robot()
    robot.place(0, 0, starting)
    robot.right()
    assert robot.orientation == expected
Exemplo n.º 9
0
def test_move(x, y, orientation, expected):
    robot = robot_sim.Robot()
    robot.place(x, y, orientation)
    robot.move()
    robot.move()
    assert (robot.x_pos, robot.y_pos, robot.orientation) == expected
Exemplo n.º 10
0
def test_invalid_place(x, y, orientation):
    robot = robot_sim.Robot()
    robot.place(0, 0, "north")
    robot.place(x, y, orientation)
    assert (robot.x_pos, robot.y_pos, robot.orientation) == (0, 0, "north")
Exemplo n.º 11
0
def test_valid_place(x, y, orientation):
    robot = robot_sim.Robot()
    robot.place(x, y, orientation)
    assert (robot.x_pos, robot.y_pos,
            robot.orientation) == (x, y, orientation.lower())
Exemplo n.º 12
0
def test_valid_pos(x, y):
    robot = robot_sim.Robot()
    assert robot.validate(x, y) is True