private static void ValidateResult <T>(T x, Node <T> list, params T[] expectedResult)
            where T : IEquatable <T>, IComparable <T>
        {
            var result = Question2_4.PartitionList(list, x);

            ListHelpers.ValidateLinkedListContent(result, expectedResult);
        }
        private static void ValidateNotReversedHelper(int num1, int num2, int expectedResult)
        {
            var expectedResultArray = CreateList(expectedResult);
            var list1  = CreateDigitList(num1);
            var list2  = CreateDigitList(num2);
            var result = Question2_5.AddNotReversed(list1, list2);

            ListHelpers.ValidateLinkedListContent(result, expectedResultArray.Select(r => new Digit(r)).ToArray());
        }
        private static void ValidateResult <T>(Node <T> input, params T[] expectedResult)
            where T : IEquatable <T>
        {
            var input1 = ListHelpers.CloneList(input);
            var input2 = ListHelpers.CloneList(input);

            Question2_1.RemoveDuplicates(input1);
            Question2_1.RemoveDuplicatesNoSpace(input2);

            ListHelpers.ValidateLinkedListContent(input1, expectedResult);
            ListHelpers.ValidateLinkedListContent(input2, expectedResult);
        }
        public void BasicTest()
        {
            // Add an element
            Node <int> head = new Node <int>(1);

            ListHelpers.ValidateLinkedListContent(head, 1);

            // Add two more elements
            head.AppendToTail(2);
            head.AppendToTail(3);
            ListHelpers.ValidateLinkedListContent(head, 1, 2, 3);

            // Remove the middle element
            head = head.DeleteNode(head, 2);
            ListHelpers.ValidateLinkedListContent(head, 1, 3);
        }
        public void RemoveTests()
        {
            // Add three elements
            Node <int> head = new Node <int>(1);

            head.AppendToTail(2);
            head.AppendToTail(3);
            ListHelpers.ValidateLinkedListContent(head, 1, 2, 3);

            // Remove the middle one
            head = head.DeleteNode(head, 2);
            ListHelpers.ValidateLinkedListContent(head, 1, 3);

            // Remove the first one
            head = head.DeleteNode(head, 1);
            ListHelpers.ValidateLinkedListContent(head, 3);

            // Remove non-existent head
            head = head.DeleteNode(head, 4);
            ListHelpers.ValidateLinkedListContent(head, 3);
        }
Ejemplo n.º 6
0
 private static void ValidateResult <T>(Node <T> list, Node <T> nodeToRemove, params T[] expectedResult)
     where T : IEquatable <T>
 {
     Question2_3.RemoveNode(nodeToRemove);
     ListHelpers.ValidateLinkedListContent(list, expectedResult);
 }