Exemple #1
0
        public void RemoveElementTest()
        {
            var testFunc = new ArrayQ();
            var testcase = new int[] { 3, 2, 2, 3 };
            var output   = testFunc.RemoveElement(testcase, 3);

            Assert.AreEqual(2, output);
            var result = GenerateResultIntOutput(testcase, output);

            ValidateArrayElements(result, new int[] { 2, 2 });

            testcase = new int[] { 0, 1, 2, 2, 3, 0, 4, 2 };
            output   = testFunc.RemoveElement(testcase, 2);
            Assert.AreEqual(5, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { 0, 1, 3, 0, 4 });

            testcase = new int[] { 3, 2, 2, 3 };
            output   = testFunc.RemoveElement(testcase, 2);
            Assert.AreEqual(2, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { 3, 3 });

            testcase = new int[] { };
            output   = testFunc.RemoveElement(testcase, 2);
            Assert.AreEqual(0, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { });

            testcase = new int[] { 1 };
            output   = testFunc.RemoveElement(testcase, 2);
            Assert.AreEqual(1, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { 1 });

            testcase = new int[] { 1 };
            output   = testFunc.RemoveElement(testcase, 1);
            Assert.AreEqual(0, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { });

            testcase = new int[] { 3, 3, 1, 2, 4, 3, 3 };
            output   = testFunc.RemoveElement(testcase, 3);
            Assert.AreEqual(3, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { 1, 2, 4 });

            testcase = new int[] { 3, 3, 1, 2, 3, 4, 3, 3 };
            output   = testFunc.RemoveElement(testcase, 3);
            Assert.AreEqual(3, output);
            result = GenerateResultIntOutput(testcase, output);
            ValidateArrayElements(result, new int[] { 1, 2, 4 });
        }