Esempio n. 1
0
def test_less_than_immediate(inp):
    ic = Intcode([3, 3, 1107, -1, 8, 3, 4, 3, 99], input_data=[inp])
    assert len(ic.output_data) == 1
    if inp < 8:
        assert ic.output_data[0] == 1
    else:
        assert ic.output_data[0] == 0
Esempio n. 2
0
def test_less_than_position(inp):
    ic = Intcode([3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8], input_data=[inp])
    assert len(ic.output_data) == 1
    if inp < 8:
        assert ic.output_data[0] == 1
    else:
        assert ic.output_data[0] == 0
Esempio n. 3
0
def test_equals_immediate(inp):
    ic = Intcode([3, 3, 1108, -1, 8, 3, 4, 3, 99], input_data=[inp])
    assert len(ic.output_data) == 1
    if inp == 8:
        assert ic.output_data[0] == 1
    else:
        assert ic.output_data[0] == 0
Esempio n. 4
0
def test_equals_position(inp):
    ic = Intcode([3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8], input_data=[inp])
    assert len(ic.output_data) == 1
    if inp == 8:
        assert ic.output_data[0] == 1
    else:
        assert ic.output_data[0] == 0
Esempio n. 5
0
def test_jump_immediate(inp):
    ic = Intcode([3, 3, 1105, -1, 9, 1101, 0, 0, 12, 4, 12, 99, 1],
                 input_data=[inp])
    assert len(ic.output_data) == 1
    if inp == 0:
        assert ic.output_data[0] == 0
    else:
        assert ic.output_data[0] == 1
Esempio n. 6
0
def test_jump_position(inp):
    ic = Intcode([3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9],
                 input_data=[inp])
    assert len(ic.output_data) == 1
    if inp == 0:
        assert ic.output_data[0] == 0
    else:
        assert ic.output_data[0] == 1
Esempio n. 7
0
def test_evaluate(code, result):
    ic = Intcode(code)
    assert ic.mem == result
    assert ic.output_data == []