Example #1
0
        public void TestAdditionDirect(long a, long b, long answer)
        {
            List <long> program = new List <long>()
            {
                1102, a, b, 0,
                99,
                2, 3
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(0), Is.EqualTo(answer));
        }
Example #2
0
        public void TestAdditionAddresses(long a, long b, long answer)
        {
            List <long> program = new List <long>()
            {
                2, 5, 6, 0,
                99,
                a, b
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(0), Is.EqualTo(answer));
        }
Example #3
0
        public void TestAdditionBaseOffset(long a, long b, long answer)
        {
            List <long> program = new List <long>()
            {
                109, 7,
                2202, 0, 1, 0,
                99,
                a, b
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(0), Is.EqualTo(answer));
        }
Example #4
0
        public void TestInputDirect(long answer)
        {
            List <long> program = new List <long>()
            {
                103, 5,
                99,
                3, 4, 5
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.AddInput(answer);
            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(1), Is.EqualTo(answer));
        }
Example #5
0
        public void TestInputAddresses(long answer)
        {
            List <long> program = new List <long>()
            {
                3, 0,
                99,
                4, 5, 6
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.AddInput(answer);
            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(0), Is.EqualTo(answer));
        }
Example #6
0
        public void TestInputBaseOffset(long answer)
        {
            List <long> program = new List <long>()
            {
                109, 3,
                203, 4,
                99,
                5, 6, 7
            };

            IntCodeVM2 vm = new IntCodeVM2(program);

            vm.AddInput(answer);
            vm.ExecuteProgram();
            Assert.That(vm.GetMemory(7), Is.EqualTo(answer));
        }