Exemplo n.º 1
0
def test_shift():
    colors = SingleLinkedList()
    colors.shift("Cadmium Orange")
    assert colors.count() == 1
    colors.shift("Carbazole Violet")
    assert colors.count() == 2
    assert colors.pop() == "Cadmium Orange"
    assert colors.count() == 1
    assert colors.pop() == "Carbazole Violet"
    assert colors.count() == 0
Exemplo n.º 2
0
 def test_push(self):
     colors = SingleLinkedList()
     colors.push('Pthalo Blue')
     assert colors.count() == 1
     colors.push('Ultramarine Bleu')
     assert colors.count() == 2
     colors.push('Magenta')
     assert colors.count() == 3
     colors.push('Green')
     assert colors.count() == 4
     colors.push('Red')
     assert colors.count() == 5
Exemplo n.º 3
0
    def test_shift(self):
        for i in range(0, 800):
            colors = SingleLinkedList()
            colors.shift("Cadium Orange")
            assert colors.count() == 1

            colors.shift("Carbazole Violet")
            assert colors.count() == 2

            assert colors.pop() == "Cadium Orange"
            assert colors.count() == 1
            assert colors.pop() == "Carbazole Violet"
            assert colors.count() == 0
Exemplo n.º 4
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
Exemplo n.º 5
0
def test_push():
    colors = SingleLinkedList()
    colors.push("Pthalo Blue")
    assert colors.count() == 1
    colors.push("Ultramarine Blue")
    assert colors.count() == 2
Exemplo n.º 6
0
def test_push():
    colors = SingleLinkedList()
    colors.push('blue')
    assert colors.count() == 1
    colors.push('red')
    assert colors.count() == 2