Beispiel #1
0
def test_erase_head():
    l = SingleLinkedList()
    l.push_front(1)
    assert l.head.data == 1

    l.erase(0)
    assert l.head == None
Beispiel #2
0
def test_erase_middle():
    l = SingleLinkedList()
    l.push_back(1)
    l.push_back(2)
    l.push_back(3)

    assert l.head.next.data == 2
    l.erase(1)
    assert l.head.next.data == 3
Beispiel #3
0
def test_erase_tail():
    l = SingleLinkedList()
    l.push_back(1)
    assert l.tail.data == 1

    l.push_back(2)
    assert l.tail.data == 2

    l.push_back(3)
    assert l.tail.data == 3

    l.erase(2)

    assert l.tail.data == 2