예제 #1
0
        public void ReorderList_ReturnsList()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 1 });
            ListNode    result    = new TLinkedList(new int[] { 1, 1 }).Head;

            this.executeFunctionInputTypeListNode(result, testInput, TestInstance.ReorderList);
        }
예제 #2
0
        public void SwapPairs_RetunsList()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 2 });
            ListNode    result    = new TLinkedList(new int[] { 2, 1 }).Head;

            this.executeFunctionInputTypeListNode(result, testInput, TestInstance.SwapPairs);
        }
예제 #3
0
        public void RotateRight_ReturnsRotatedList()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 1, 2, 2, 3, 3, 6 });
            ListNode    result    = new TLinkedList(new int[] { 1, 1, 2, 2, 3, 3, 6 }).Head;

            this.executeFunctionInputTypeListNodeInt(result, testInput, TestInstance.RotateRight, 70);
        }
예제 #4
0
        public void LPalin_ReturnInt()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 2, 1 });
            ListNode    response  = TestInstance.deleteDuplicates(testInput.Head);
            ListNode    result    = testInput.Head;

            // Assert
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #5
0
        public void ReverseBetween_ReturnReversedList()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 2, 3, 4, 5 });
            ListNode    result    = new TLinkedList(new int[] { 5, 4, 3, 2, 1 }).Head;
            ListNode    response  = TestInstance.ReverseBetween(testInput.Head, 1, 5);

            // Assert the test.
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #6
0
        public void deleteDuplicates_ReturnsList()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 1, 2, 2, 3, 4, 4, 5, 5, 6 });
            ListNode    result    = new TLinkedList(new int[] { 1, 2, 3, 4, 5, 6 }).Head;

            ListNode response = TestInstance.deleteDuplicates(testInput.Head);

            // Assert the test.
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #7
0
        public void AddTwoNumbers_ReturnSumAsList()
        {
            TLinkedList testInput1 = new TLinkedList(new int[] { 9, 9 });
            TLinkedList testInput2 = new TLinkedList(new int[] { 9, 9 });
            ListNode    result     = new TLinkedList(new int[] { 8, 9, 1 }).Head;
            ListNode    response   = TestInstance.addTwoNumbers(testInput1.Head, testInput2.Head);

            // Assert the test.
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #8
0
        public void RemoveNthFromEnd_ReturnHead()
        {
            TLinkedList testInput = new TLinkedList(new int[] { 1, 1, 2, 2, 3, 4, 4, 5, 5, 6 });
            ListNode    result    = new TLinkedList(new int[] { 1, 2, 2, 3, 4, 4, 5, 5, 6 }).Head;


            ListNode response = TestInstance.RemoveNthFromEnd(testInput.Head, 15);

            // Assert the test.
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #9
0
        public void mergeTwoLists_returnListHead()
        {
            TLinkedList testInput_1 = new TLinkedList(new int[] { 1, 2, 3 });
            TLinkedList testInput_2 = new TLinkedList(new int[] { 4, 5, 6 });
            ListNode    result      = new TLinkedList(new int[] { 1, 2, 3, 4, 5, 6 }).Head;

            ListNode response = TestInstance.MergeTwoLists(testInput_1.Head, testInput_2.Head);

            // Assert the test.
            Assert.IsTrue(this.compareLinkedLists(result, response));
        }
예제 #10
0
        private void executeFunctionInputTypeListNodeInt(ListNode result, TLinkedList testInput, Func <ListNode, int, ListNode> f, int pos)
        {
            ListNode response = f(testInput.Head, pos);

            Assert.IsTrue(this.compareLinkedLists(result, response));
        }