This commit is contained in:
perro tuerto 2023-05-11 15:34:41 -07:00
parent d57d18e326
commit a4d0af8187
2 changed files with 7 additions and 8 deletions

View File

@ -1,5 +1,4 @@
class SingleLinkedListNode(object):
def __init__(self, value):
self.value = value
self.next = None
@ -102,8 +101,8 @@ class SingleLinkedList(object):
count += 1
node = node.next
if node.next:
node.value = node.next.value
node.next = node.next.next
node.value = node.next.value
node.next = node.next.next
else:
node = None
return count

View File

@ -1,4 +1,4 @@
from sllist import *
from sllist import SingleLinkedList
def test_push():
@ -17,7 +17,7 @@ def test_pop():
assert colors.count() == 1
assert colors.pop() == "Magenta"
assert colors.count() == 0
assert colors.pop() == None
assert colors.pop() is None
def test_get():
@ -34,11 +34,11 @@ def test_get():
assert colors.pop() == "Cadmium Yellow Light"
assert colors.get(0) == "Vermillion"
assert colors.get(1) == "Sap Green"
assert colors.get(2) == None
assert colors.get(2) is None
colors.pop()
assert colors.get(0) == "Vermillion"
colors.pop()
assert colors.get(0) == None
assert colors.get(0) is None
def test_unshift():
@ -49,7 +49,7 @@ def test_unshift():
assert colors.unshift() == "Viridian"
assert colors.unshift() == "Sap Green"
assert colors.unshift() == "Van Dyke"
assert colors.unshift() == None
assert colors.unshift() is None
assert colors.count() == 0