def test_cast_linked_list_to_list(self): linked_list = LinkedList() third = Node(3) second = Node(2, third) first = Node(1, second) linked_list.head = first assert linked_list.to_list() == [1, 2, 3]
def test_create_linked_list_with_three_nodes(self): linked_list = LinkedList() linked_list.head = Node(1) second = Node(2) third = Node(3) assert linked_list.head.data == 1 assert not linked_list.head.next assert not second.next assert not third.next linked_list.head.next = second second.next = third assert linked_list.head.next.data == 2 assert linked_list.head.next.next.key == 3 assert not linked_list.head.next.next.next