def test_insert_multiple_node():
    x = LinkedList()
    x.insert("a")
    x.insert("b")
    x.insert("c")
    x.insert("d")
    x.insert("e")
    actual = x.contains()
    expected = ["e", "d", "c", "b", "a"]
    assert actual == expected
Example #2
0
def test_can_successfully_add_a_node_to_the_end_of_the_linked_list():
    x = LinkedList()
    x.insert("a")
    x.insert("b")
    x.insert("c")
    x.insert("d")
    x.insert("e")
    x.append("g")
    actual = x.contains()
    expected = ["e","d","c","b","a","g"]
    assert actual == expected
Example #3
0
def test_can_successfully_insert_a_node_before_the_first_node_of_a_linked_list():
    x = LinkedList()
    x.insert("a")
    x.insert("b")
    x.insert("c")
    x.insert("d")
    x.insert("e")
    x.insert_before("e", "test")
    actual = x.contains()
    expected = ["test","e","d","c","b","a"]
    assert actual == expected
Example #4
0
def test_can_successfully_insert_a_node_after_the_last_node_of_the_linked_list():
    x = LinkedList()
    x.insert("a")
    x.insert("b")
    x.insert("c")
    x.insert("d")
    x.insert("e")
    x.insert_after("a", "test")
    actual = x.contains()
    expected = ["e","d","c","b","a","test"]
    assert actual == expected
Example #5
0
def test_can_successfully_add_multiple_nodes_to_the_end_of_a_linked_list():
    x = LinkedList()
    x.insert("a")
    x.insert("b")
    x.insert("c")
    x.insert("d")
    x.insert("e")
    x.append("test one")
    x.append("test two")
    actual = x.contains()
    expected = ["e","d","c","b","a", "test one", "test two"]
    assert actual == expected