def test_merge_sorted(self): ll1 = from_array_list([1, 3, 5, 7, 9]) ll2 = from_array_list([1, 4, 6, 8]) head = merge_sorted(ll1.head, ll2.head) ll = LinkedList() ll.head = head self.assertEqual([1, 1, 3, 4, 5, 6, 7, 8, 9], ll.to_list())
def test_to_list(self): ll = LinkedList() ll.head = Node(1) ll.head.next = Node(2) ll.head.next.next = Node(3) self.assertEqual([1, 2, 3], ll.to_list())
def test_last(self): ll = LinkedList() ll.head = Node(1) ll.head.next = Node(2) ll.head.next.next = Node(3) self.assertEqual(3, ll.length())