示例#1
0
    def test_rel_base_offset_3(self):
        # arrange
        program = [104, 1125899906842624, 99]
        c = Compute(program)

        # act
        c.LoadInput([])
        c.LoadProgram(program)
        result = c.RunCompute()

        # assert
        self.assertEqual(result, 1125899906842624)
示例#2
0
    def test_rel_base_offset_2(self):
        # arrange
        program = [1102, 34915192, 34915192, 7, 4, 7, 99, 0]
        results = []
        c = Compute(program)

        # act
        c.LoadInput([])
        c.LoadProgram(program)
        output = c.RunCompute()
        result = len([int(d) for d in str(output)])

        # assert
        self.assertEqual(result, 16)
示例#3
0
    def test_jump_position(self):
        # arrange
        program = [3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9]
        testvalues = [1, -8, 0]
        results = []
        c = Compute(program)

        # act
        for v in testvalues:
            c.LoadInput([v])
            c.LoadProgram(program)
            results.append(c.RunCompute())

        # assert
        self.assertEqual(results, [1, 1, 0])
示例#4
0
    def test_jump_immediate(self):
        # arrange
        program = [3, 3, 1105, -1, 9, 1101, 0, 0, 12, 4, 12, 99, 1]
        testvalues = [0, 1, -9]
        results = []
        c = Compute(program)

        # act
        for v in testvalues:
            c.LoadInput([v])
            c.LoadProgram(program)
            results.append(c.RunCompute())
            # print(c.GetOutputs())

        # assert
        self.assertEqual(results, [0, 1, 1])