def test_linked_list_insert_after(): ll = LinkedList() ll.head = Node(1) ll.head.next = Node(2) ll.insert_after(1, 4) assert ll.head.next.value == 4 assert ll.head.next.next.value == 2
def test_linked_list_insert_after(): """Test a value can be inserted after a value already in the linked list.""" linked_list = LinkedList() value = 1 linked_list.insert(value) new_value = 2 linked_list.insert_after(value, new_value) assert linked_list.head.next.value == new_value assert linked_list.head.next.next == None newer_value = 3 linked_list.insert_after(value, newer_value) assert linked_list.head.next.value == newer_value assert linked_list.head.next.next.value == new_value assert linked_list.head.next.next.next == None