def test_day_5_part_2(day_5_input): stack_io_handler = StackIOHandler([str(5)]) machine = IntCodeMachine(day_5_input, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack[-1] == "11189491"
def test_day_5_large_test(input, expected_output): code = "3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99" # noqa: E501 stack_io_handler = StackIOHandler([str(input)]) machine = IntCodeMachine(code, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack == [str(expected_output)]
def test_day_5_part_1(day_5_input): stack_io_handler = StackIOHandler([str(1)]) machine = IntCodeMachine(day_5_input, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack[-1] == "13978427"
def test_day_5_jump(program, input, expected_output): stack_io_handler = StackIOHandler([str(input)]) machine = IntCodeMachine(program, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack == [str(expected_output)]
def test_day_9(day_9_input, input, expected_output): stack_io_handler = StackIOHandler([input]) machine = IntCodeMachine(day_9_input, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack[-1] == expected_output
def test_middle_number(): stack_io_handler = StackIOHandler() code = "104,1125899906842624,99" machine = IntCodeMachine(code, io_handler=stack_io_handler) machine.run() assert stack_io_handler.io_stack[-1] == "1125899906842624"
def test_16_length_number(): stack_io_handler = StackIOHandler() code = "1102,34915192,34915192,7,4,7,99,0" machine = IntCodeMachine(code, io_handler=stack_io_handler) machine.run() assert len(stack_io_handler.io_stack[-1]) == 16
def test_quine(): stack_io_handler = StackIOHandler() code = "109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99" machine = IntCodeMachine(code, io_handler=stack_io_handler) machine.run() assert code.split(',') == stack_io_handler.io_stack