Esempio n. 1
0
def test_remove_head_node_length1():
    my_linked_list = LinkedList()
    my_linked_list.append_node(0)
    my_linked_list.remove_head_node()
    assert my_linked_list.get_node_count() == 0
    assert my_linked_list.get_head_node() is None
    assert my_linked_list.get_value_at_position(0) is None    
Esempio n. 2
0
def test_remove_duplicate_values_length1():
    my_linked_list = LinkedList()
    my_linked_list.append_node(0)
    my_linked_list.remove_duplicate_values()
    assert my_linked_list.get_node_count() == 1
    assert my_linked_list.get_head_node().value == 0
    assert my_linked_list.get_value_at_position(0) == 0
Esempio n. 3
0
def test_single_node():
    my_linked_list = LinkedList()
    my_linked_list.append_node(0)
    assert my_linked_list.get_node_count() == 1
    assert my_linked_list.get_head_node().value == 0
    assert my_linked_list.get_value_at_position(0) == 0
    assert my_linked_list.get_value_at_position(1) is None
    assert my_linked_list.get_value_at_position(1) is None
Esempio n. 4
0
def test_compare_lists_length1():
    linked_list_1 = LinkedList()
    linked_list_1.append_node(0)
    linked_list_2 = LinkedList()
    linked_list_2.append_node(0)
    assert linked_list_1.compare_to(linked_list_2)
    linked_list_2.set_value_at_position(1, 0)
    assert not linked_list_1.compare_to(linked_list_2)
Esempio n. 5
0
def test_remove_all_nodes_with_value_length2():
    my_linked_list = LinkedList()
    my_linked_list.append_nodes([0, 1])
    my_linked_list.remove_all_nodes_with_value(1)
    assert my_linked_list.get_node_count() == 1
    assert my_linked_list.get_head_node().value == 0
    my_linked_list.append_node(1)
    my_linked_list.remove_all_nodes_with_value(0)
    assert my_linked_list.get_node_count() == 1
    assert my_linked_list.get_head_node().value == 1
    assert my_linked_list.get_value_at_position(2) is None