def test_command_20101(self): code = [20101, 5, 1, -5, 99, 0] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:6], [20101, 5, 1, -5, 99, 10])
def test_command_2105(self): code = [2105, 1, -7, 4, 99] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertTrue(True)
def test_command_20001(self): code = [20001, 5, 6, -3, 99, 2, 4, 0] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:8], [20001, 5, 6, -3, 99, 2, 4, 6])
def test_command_21001(self): code = [21001, 5, 1, -4, 99, 2, 0] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:7], [21001, 5, 1, -4, 99, 2, 3])
def test_203_input(self): code = [203, -6, 99, -1, -1] computer = Intcomputer(code) computer.relative_base = 10 status, out = computer.execute(1) self.assertEqual(computer.memory[:5], [203, -6, 99, -1, 1])
def test_21107_less_than(self): code = [21107, 1, 2, -5, 99, -1] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:6], [21107, 1, 2, -5, 99, 1])
def test_jump_if_false_mode_2(self): code = [1206, 3, 4, 1, 99, 0] computer = Intcomputer(code) computer.relative_base = 2 computer.execute() self.assertTrue(True)
def test_command_201(self): code = [201, -4, 5, 7, 99, 3, 1, 0] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:8], [201, -4, 5, 7, 99, 3, 1, 4])
def test_mul_mode_12(self): code = [1202, -5, 2, 3, 99, 6] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:6], [1202, -5, 2, 12, 99, 6])
def test_jump_if_true_mode_2_b(self): code = [205, 3, 6, 0, 99, 1, 4] computer = Intcomputer(code) computer.relative_base = 2 computer.execute() self.assertTrue(True)
def test_add_mode_12(self): code = [1201, -5, 5, 3, 99, 11] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:6], [1201, -5, 5, 16, 99, 11])
def test_add_mode_21(self): code = [2101, 5, -5, 6, 99, 11] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.memory[:7], [2101, 5, -5, 6, 99, 11, 16])
def test_adjust_relative_mode_2(self): code = [209, -1, 99, 20] computer = Intcomputer(code) computer.relative_base = 4 computer.execute() self.assertEqual(computer.relative_base, 24)
def test_command_109(self): code = [109, -1, 99] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertEqual(computer.relative_base, 9)
def test_command_1206(self): code = [1206, -7, 4, 0, 99] computer = Intcomputer(code) computer.relative_base = 10 computer.execute() self.assertTrue(True)