def test_remove_all_nodes_with_value_empty(): my_linked_list = LinkedList() my_linked_list.remove_all_nodes_with_value(0) 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 assert my_linked_list.get_value_at_position(1) is None
def test_remove_all_nodes_with_value_multiple_at_start_and_end(): my_linked_list = LinkedList() input_values = [0, 0, 0, 0, 0, 1, 0, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0] expected_output_values = [1, 2, 3, 4, 5, 6, 7, 8, 9] my_linked_list.append_nodes(input_values) my_linked_list.remove_all_nodes_with_value(0) actual_output_values = linked_list_values_to_array(my_linked_list) assert expected_output_values == actual_output_values
def test_remove_all_nodes_with_value_not_in_list(): my_linked_list = LinkedList() input_values = [1, 2, 3, 4, 5, 6, 7, 8, 9] my_linked_list.append_nodes(input_values) my_linked_list.remove_all_nodes_with_value(0) expected_output_values = [1, 2, 3, 4, 5, 6, 7, 8, 9] actual_output_values = linked_list_values_to_array(my_linked_list) assert expected_output_values == actual_output_values
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