public void Works(int[] sourceArr, bool expected)
    {
        var list = DebugLinkedListFactory.Create <PalindromeListChecker.ListNode>(sourceArr);

        bool result = new PalindromeListChecker().IsPalindrome(list);

        result.Should().Be(expected);
    }
예제 #2
0
    public void Works(int[] arr1, int[] arr2, int[] expectedValues)
    {
        ListNode l1 = DebugLinkedListFactory.Create <ListNode>(arr1);
        ListNode l2 = DebugLinkedListFactory.Create <ListNode>(arr2);

        ListNode result = new AddTwoNumbersSolver().AddTwoNumbers(l1, l2);

        ListNode currentNode = result;

        foreach (int expectedVal in expectedValues)
        {
            currentNode.Val.Should().Be(expectedVal);
            currentNode = currentNode.Next;
        }
    }
    public static object[][] ReverseBetweenTestData()
    {
        return(new[]
        {
            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1 }), 1, 1, new[] { 1 } },

            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2 }), 1, 1, new[] { 1, 2 } },
            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2 }), 2, 2, new[] { 1, 2 } },
            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2 }), 1, 2, new[] { 2, 1 } },

            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2, 3, 4, 5 }), 3, 3, new[] { 1, 2, 3, 4, 5 } },
            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2, 3, 4, 5 }), 2, 4, new[] { 1, 4, 3, 2, 5 } },
            new object[] { DebugLinkedListFactory.Create <ListNode>(new[] { 1, 2, 3, 4, 5 }), 1, 5, new[] { 5, 4, 3, 2, 1 } },
        });
    }