Last active
January 29, 2025 11:00
-
-
Save zedr/aedaffe1ba8667c10d84968ee6918ae9 to your computer and use it in GitHub Desktop.
linked_lists_tests.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implement a file named linked_lists.py | |
from linked_lists import LinkedList, Node | |
# Part 1 - tests for the nodes of a linked list | |
head_node = Node("Napoli") | |
assert head_node.next is None | |
head_node.next = Node("Rome") | |
head_node.next.next = Node("Milan") | |
# Part 2 - tests for the linked list | |
my_list = LinkedList() | |
assert len(my_list) == 0 | |
assert my_list.head is None | |
my_list.add_node(data="Napoli") | |
assert len(my_list) == 1 | |
assert my_list.head.data == "Napoli" | |
my_list.add_node(data="Milan") | |
assert len(my_list) == 2 | |
# Check that we have two objects of type Node | |
assert [type(el) for el in my_list] == [Node, Node] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment