Esempio n. 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
Esempio n. 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
Esempio n. 3
0
def test_last():
    colors = SingleLinkedList()
    colors.push("Cadmium Red Light")
    assert colors.last() == "Cadmium Red Light"
    colors.push("Hansa Yellow")
    assert colors.last() == "Hansa Yellow"
    colors.shift("Pthalo Green")
    assert colors.last() == "Hansa Yellow"
Esempio n. 4
0
 def test_last(self):
     colors = SingleLinkedList()
     colors.push('Cadmium Red Light')
     assert colors.last() == 'Cadmium Red Light'
     colors.push('Hansa Yellow')
     assert colors.last() == 'Hansa Yellow'
     colors.shift('Pthalo Green')
     assert colors.last() == 'Hansa Yellow'
Esempio n. 5
0
 def test_first(self):
     for i in range(0, 800):
         colors = SingleLinkedList()
         colors.push('Cadmium Red Light')
         assert colors.first() == 'Cadmium Red Light'
         colors.push('Hansa Yellow')
         assert colors.first() == 'Cadmium Red Light'
         colors.shift('Pthalo Green')
         assert colors.first() == 'Pthalo Green'
Esempio n. 6
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
Esempio n. 7
0
def test_remove():
    colors = SingleLinkedList()
    colors.push("Cobalt")
    colors.push("Zinc White")
    colors.push("Nickle Yellow")
    colors.push("Perinone")
    assert colors.remove("Cobalt") == 0
    assert colors.remove("Perinone") == 2
    assert colors.remove("Nickle Yellow") == 1
    assert colors.remove("Zinc White") == 0
Esempio n. 8
0
 def test_remove(self):
     colors = SingleLinkedList()
     colors.push('Cobalt')
     colors.push('Zinc White')
     colors.push('Nickle Yellow')
     colors.push('Perinone')
     assert colors.remove('Nickle Yellow') == 2
     # colors.dump('before perinone')
     assert colors.remove('Perinone') == 2
     # colors.dump('after perinone')
     assert colors.remove('Zinc White') == 1
Esempio n. 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
Esempio n. 10
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]'
Esempio n. 11
0
 def test_unshift(self):
     colors = SingleLinkedList()
     colors.push('Viridian')
     colors.push('Sap Green')
     colors.push('Van Dyke')
     assert colors.unshift() == 'Viridian'
     assert colors.unshift() == 'Sap Green'
     assert colors.unshift() == 'Van Dyke'
     assert colors.unshift() is None
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
0
def test_unshift():
    colors = SingleLinkedList()
    colors.push("Viridian")
    colors.push("Sap Green")
    colors.push("Van Dyke")
    assert colors.unshift() == "Viridian"
    assert colors.unshift() == "Sap Green"
    assert colors.unshift() == "Van Dyke"
    assert colors.unshift() is None
Esempio n. 15
0
def test_last():
    colors = SingleLinkedList()
    colors.push('red')
    assert colors.last() == 'red'

    colors.push('yellow')
    assert colors.last() == 'yellow'

    colors.push('blue')
    assert colors.last() == 'blue'
Esempio n. 16
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
Esempio n. 17
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
Esempio n. 18
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
Esempio n. 19
0
def test_push():
    colors = SingleLinkedList()
    colors.push("Pthalo Blue")
    assert colors.count() == 1
    colors.push("Ultramarine Blue")
    assert colors.count() == 2
Esempio n. 20
0
def test_push():
    colors = SingleLinkedList()
    colors.push('blue')
    assert colors.count() == 1
    colors.push('red')
    assert colors.count() == 2