Exemple #1
0
def test_remove_front_back():
    dllist = DLList()
    dllist.add(0, 100)
    dllist.remove(0) == 100
    dllist.remove(1) == None
    dllist.add(0, 200)
    dllist.add(1, 150)
    dllist.add(2, 300)
    
    assert dllist.remove(0) == 200
    x = dllist.dummy.front.front
    assert x.back.data == 150
    assert x.data == 300
Exemple #2
0
def test_remove():
    dllist= DLList()
    assert dllist.remove(0) == None
    dllist.add(0, 10)
    dllist.add(1, 20)
    dllist.add(2, 100)
    dllist.add(3, 40)
    assert dllist.remove(1) ==20
    assert dllist.size == 3
    assert dllist.dummy.front.data == 10
    assert dllist.remove(0) ==10
    assert dllist.dummy.front.data == 100
    assert dllist.size == 2
    assert dllist.remove(1) ==40
    assert dllist.dummy.back.data == 100
    assert dllist.size == 1
Exemple #3
0
def test_remove_head_tail():
    dllist = DLList()
    dllist.add(0, 10)
    dllist.add(1, 20)
    dllist.add(2, 100)
    dllist.add(3, 40)

    assert dllist.remove(0) == 10
    assert dllist.dummy.front.data == 20
    assert dllist.dummy.back.data == 40
    assert dllist.size == 3
    assert dllist.get(0) == 20
    assert dllist.get(1) == 100