예제 #1
0
파일: Test_2_1.cs 프로젝트: jkrez/Interview
        public void Question_2_1_InvalidCases()
        {
            Node <int> head = null;

            TestHelpers.AssertExceptionThrown(() => Question_2_1.RemoveDuplicates(head), typeof(ArgumentNullException));
            TestHelpers.AssertExceptionThrown(() => Question_2_1.RemoveDuplicatesNoSpace(head), typeof(ArgumentNullException));
        }
        public void RemoveDuplicatesInplaceTest_SingleNode()
        {
            var testList     = new LinkedList(new int[] { 1 });
            var expectedList = new LinkedList(new int[] { 1 });

            Question_2_1.RemoveDuplicatesInplace(testList);
            Assert.AreEqual(expectedList, testList);
        }
        public void RemoveDuplicatesTest()
        {
            var testList     = new LinkedList(new int[] { 1, 2, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1, 10, 1 });
            var expectedList = new LinkedList(new int[] { 1, 2, 3, 4, 5, 6, 10 });

            Question_2_1.RemoveDuplicates(testList);
            Assert.AreEqual(expectedList, testList);
        }
        public void RemoveDuplicatesInplaceTest_EmptyList()
        {
            var testList     = new LinkedList();
            var expectedList = new LinkedList();

            Question_2_1.RemoveDuplicatesInplace(testList);
            Assert.AreEqual(expectedList, testList);
        }
예제 #5
0
파일: Test_2_1.cs 프로젝트: jkrez/Interview
        private void ValidateResult <T>(Node <T> expected, Node <T> input)
            where T : IEquatable <T>
        {
            var inputCopy  = ListHelpers.CloneList(input);
            var inputCopy2 = ListHelpers.CloneList(input);

            Question_2_1.RemoveDuplicates(inputCopy);
            ListHelpers.ValidateLinkedListContent(expected, inputCopy);
            Question_2_1.RemoveDuplicatesNoSpace(input);
            ListHelpers.ValidateLinkedListContent(expected, input);
            Question_2_1.RemoveDuplicatesNoSpace2(inputCopy2);
            ListHelpers.ValidateLinkedListContent(expected, input);
        }