Ejemplo n.º 1
0
def test_invalid_instruction(capsys):
    instructions = """
        PLACE
        REPORT
    """
    robot = Robot()
    with pytest.raises(InvalidInstruction):
        robot.simulate(instructions)
Ejemplo n.º 2
0
def test_incorect_placement(capsys):
    instructions = """
        PLACE 6,6,EAST
        REPORT
    """
    robot = Robot()
    with pytest.raises(InvalidInstruction):
        robot.simulate(instructions)
Ejemplo n.º 3
0
def test1(capsys):
    instructions = """
        PLACE 0,0,NORTH
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "0,1,NORTH", "Example 1 failed"
Ejemplo n.º 4
0
def test2(capsys):
    instructions = """
        PLACE 0,0,NORTH
        LEFT
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "0,0,WEST", "Example 2 failed"
Ejemplo n.º 5
0
def test_proper_start(capsys):
    instructions = """
        MOVE
        RIGHT
        PLACE 5,5,EAST
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip(
    ) == "5,5,EAST", "Failed finding the starting instruction"
Ejemplo n.º 6
0
def test3(capsys):
    instructions = """
        PLACE 1,2,EAST
        MOVE
        MOVE
        LEFT
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "3,3,NORTH", "Example 3 failed"
Ejemplo n.º 7
0
def test_overboundary2(capsys):
    instructions = """
        PLACE 5,5,EAST
        MOVE
        LEFT
        MOVE
        LEFT
        MOVE
        REPORT
    """
    robot = Robot()
    robot.simulate(instructions)
    captured = capsys.readouterr()
    assert captured.out.strip() == "4,5,WEST", "Failed boundary test 2"