Exemple #1
0
        public void insertInstructionPositive1()   // test if insertion of an instruction in the positive side works correctly
        {
            InstructionOffsetPreservingArray arr = new InstructionOffsetPreservingArray();

            arr.append((int)InstructionInterpreter.convInstructionAndRelativeToInstruction(3, 0)); // jump 0
            arr.append(10);

            arr.insert(1, 11);

            Assert.AreEqual(arr[0], (int)InstructionInterpreter.convInstructionAndRelativeToInstruction(3, 1)); // must be jump 1
            Assert.AreEqual(arr[1], 11);
            Assert.AreEqual(arr[2], 10);
        }
Exemple #2
0
        public void insertInstructionNegative2()   // test if insertion of an instruction in the negative side works correctly
        {
            InstructionOffsetPreservingArray arr = new InstructionOffsetPreservingArray();

            arr.append(10);
            arr.append((int)InstructionInterpreter.convInstructionAndRelativeToInstruction(3, -2)); // jump -2

            arr.insert(1, 11);

            Assert.AreEqual(arr[0], 10);
            Assert.AreEqual(arr[1], 11);
            Assert.AreEqual(arr[2], (int)InstructionInterpreter.convInstructionAndRelativeToInstruction(3, -3));
        }