def test_cmd01_position(self): code = Intcode([1, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd01() assert code.program == [1, 9, 10, 70, 2, 3, 11, 0, 99, 30, 40, 50] assert code.pointer == 4 assert not code.terminated
def test_cmd01_immediate3(self): code = Intcode([1101, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd01() assert code.parm1 assert code.parm2 assert not code.parm3 assert code.program == defaultdict( int, enumerate([1101, 9, 10, 19, 2, 3, 11, 0, 99, 30, 40, 50])) assert code.pointer == 4 assert not code.terminated
def test_cmd01_relative11(self): code = Intcode([201, 9, 10, 3, 2, 3, 11, 0, 99, 30, 40, 50], 9, 10) code.relative_base = 1 operation = f'{code.program[code.pointer]:>05}' code.parm3, code.parm2, code.parm1 = map(int, tuple(operation[0:3])) code.cmd01() assert code.parm1 assert not code.parm2 assert not code.parm3 assert code.program == defaultdict( int, enumerate([201, 9, 10, 80, 2, 3, 11, 0, 99, 30, 40, 50])) assert code.pointer == 4 assert not code.terminated