예제 #1
0
def test_pop():
    colors = SingleLinkedList()
    colors.push("Magenta")
    colors.push("Alizarin")
    assert colors.pop() == "Alizarin"
    assert colors.pop() == "Magenta"
    assert colors.pop() is None
예제 #2
0
def test_pop():
    colors = SingleLinkedList()
    colors.push('magenta')
    colors.push('red')
    assert colors.pop() == 'red'
    assert colors.pop() == 'magenta'
    assert colors.pop() == None
예제 #3
0
 def test_pop(self):
     colors = SingleLinkedList()
     colors.push('Magenta')
     colors.push('Alizarin')
     colors.push('Blue')
     assert colors.pop() == 'Blue'
     assert colors.pop() == 'Alizarin'
     assert colors.pop() == 'Magenta'
     assert colors.pop() is None
예제 #4
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
예제 #5
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
예제 #6
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]'
예제 #7
0
def test_get():
    colors = SingleLinkedList()
    colors.push("Vermillion")
    assert colors.get(0) == "Vermillion"
    colors.push("Sap Green")
    assert colors.get(0) == "Vermillion"
    assert colors.get(1) == "Sap Green"
    colors.push("Cadmium Yellow Light")
    assert colors.get(0) == "Vermillion"
    assert colors.get(1) == "Sap Green"
    assert colors.get(2) == "Cadmium Yellow Light"
    assert colors.pop() == "Cadmium Yellow Light"
    assert colors.get(0) == "Vermillion"
    assert colors.get(1) == "Sap Green"
    assert colors.get(2) == None
    colors.pop()
    assert colors.get(0) == "Vermillion"
    colors.pop()
    assert colors.get(0) == None
예제 #8
0
 def test_get(self):
     colors = SingleLinkedList()
     colors.push('Vermillion')
     assert colors.get(0) == 'Vermillion'
     colors.push('Sap Green')
     assert colors.get(0) == 'Vermillion'
     assert colors.get(1) == 'Sap Green'
     colors.push('Cadmium Yellow Light')
     assert colors.get(0) == 'Vermillion'
     assert colors.get(1) == 'Sap Green'
     assert colors.get(2) == 'Cadmium Yellow Light'
     assert colors.pop() == 'Cadmium Yellow Light'
     assert colors.get(0) == 'Vermillion'
     assert colors.get(1) == 'Sap Green'
     assert colors.get(2) is None
     colors.pop()
     assert colors.get(0) == 'Vermillion'
     colors.pop()
     assert colors.get(0) is None
예제 #9
0
def test_get():
    colors = SingleLinkedList()
    colors.push('red')
    assert colors.get(0) == 'red'

    colors.push('yellow')
    assert colors.get(0) == 'red'
    assert colors.get(1) == 'yellow'

    colors.push('green')
    assert colors.get(0) == 'red'
    assert colors.get(1) == 'yellow'
    assert colors.get(2) == 'green'

    colors.pop()
    assert colors.get(0) == 'red'
    assert colors.get(1) == 'yellow'
    assert colors.get(2) == None

    colors.pop()
    assert colors.get(0) == 'red'
    assert colors.get(1) == None
    assert colors.get(2) == None

    colors.pop()
    assert colors.get(0) == None
    assert colors.get(1) == None
    assert colors.get(2) == None