Beispiel #1
0
def test_popleft():
    colors = SingleLinkedList()
    colors.push('purple')
    colors.push('green')
    colors.push('yellow')
    assert colors.popleft() == 'purple'
    assert colors.popleft() == 'green'
    assert colors.popleft() == 'yellow'
    assert colors.popleft() == None
Beispiel #2
0
def test_dump():
    colors = SingleLinkedList()
    colors.push('red')
    colors.push('white')
    colors.push('blue')
    colors.push('yellow')
    assert colors.dump() == '[red, white, blue, yellow]'

    colors.remove('white')
    assert colors.dump() == '[red, blue, yellow]'

    colors.pop()
    assert colors.dump() == '[red, blue]'

    colors.popleft()
    assert colors.dump() == '[blue]'