예제 #1
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]'
예제 #2
0
def test_remove():
    colors = SingleLinkedList()
    colors.push('red')
    colors.push('white')
    colors.push('blue')
    colors.push('yellow')
    assert colors.count() == 4

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

    assert colors.remove('blue') == True
    assert colors.count() == 2

    assert colors.remove('banana') == False

    assert colors.remove('yellow') == True
    assert colors.count() == 1