Example #1
0
def test_to_linked_list_1():
    head = to_linked_list([1, 2])

    assert isinstance(head, ListNode)
    assert head.val == 1

    assert isinstance(head.next, ListNode)
    assert head.next.val == 2

    assert head.next.next is None
Example #2
0
def test_solution(in_list, out_list):
    head = to_linked_list(in_list)
    assert to_list(Solution().reverseList(head)) == out_list
Example #3
0
def test_solution(head_array, n, expected_array):
    head = to_linked_list(head_array)
    expected = to_linked_list(expected_array)

    assert is_equal(Solution().removeNthFromEnd(head, n), expected)
Example #4
0
def test_solution(in_list, expected_out_list):
    head = to_linked_list(in_list)
    Solution().reorderList(head)
    assert to_list(head) == expected_out_list
def test_solution(items, num):
    assert Solution().getDecimalValue(to_linked_list(items)) == num
Example #6
0
def test_solution(input_array, expected_array):
    head = to_linked_list(input_array)
    middle_node = Solution().middleNode(head)
    result_array = to_list(middle_node)
    assert result_array == expected_array
def test_solution(l1, l2, expected):
    result = Solution().mergeTwoLists(to_linked_list(l1), to_linked_list(l2))
    assert is_equal(result, to_linked_list(expected))
def test_solution(head_lst, result_lst):
    head_node = to_linked_list(head_lst)
    result_node = Solution().deleteDuplicates(head_node)
    assert to_list(result_node) == result_lst
def test_solution(in_list, expected):
    head = to_linked_list(in_list)
    assert Solution().isPalindrome(head) is expected
def test_reverse(in_list, out_list):
    head = to_linked_list(in_list)
    result = reverse(head)
    assert to_list(result) == out_list
def test_solution(lists, expected_list):
    heads = [to_linked_list(x) for x in lists]
    assert to_list(Solution().mergeKLists(heads)) == expected_list
def test_merge_lists(l1_array, l2_array, expected_list):
    l1 = to_linked_list(l1_array)
    l2 = to_linked_list(l2_array)

    assert to_list(Solution().mergeLists(l1, l2)) == expected_list
Example #13
0
def test_to_linked_list_2(lst, expected_head):
    assert is_equal(to_linked_list(lst), expected_head)