def test_print(): list1 = Linked_List() list1.insert("John") list1.insert("Paul") list1.insert("George") list1.insert("Ringo") assert list1.__str__() == "('Ringo', 'George', 'Paul', 'John')" list2 = Linked_List() assert list2.__str__() == "()" list1.pop() assert list1.__str__() == "('George', 'Paul', 'John')"
def test_size(): s = Linked_List() assert s.size() is 0 for something in range(100): s.insert(something) assert s.size() is 100 s.pop() assert s.size() is 99 s.insert(0) assert s.size() is 100 m = List_Node(0) s.remove(m) assert s.size() is 99
class Stack: def __init__(self): self._lst = Linked_List() def push(self, datum): self._lst.insert(datum) def pop(self): return self._lst.pop()
def test_size(): lst = Linked_List() lst.insert(0) lst.insert(1) lst.insert(45) lst.insert('turds') assert lst.size() == 4 assert lst.head.datum == 'turds' lst.pop() lst.pop() assert lst.size() == 2 assert lst.head.datum == 1 lst.insert('boobies') assert lst.size() == 3 lst.insert('i am mature') assert lst.size() == 4 lst.pop() assert lst.head.datum == 'boobies'
def test_pop(): lst = Linked_List() lst.insert(7) lst.insert('Sir Sean Connery') val1 = lst.pop() val2 = lst.pop() assert val1 == 'Sir Sean Connery' assert val2 == 7 assert lst.head is None
class Stack: def __init__(self): self._lst= Linked_List() def push(self, datum): self._lst.insert(datum) def pop(self): return self._lst.pop()
def test_size(): lst= Linked_List() lst.insert(0) lst.insert(1) lst.insert(45) lst.insert('turds') assert lst.size()==4 assert lst.head.datum=='turds' lst.pop() lst.pop() assert lst.size()==2 assert lst.head.datum==1 lst.insert('boobies') assert lst.size()==3 lst.insert('i am mature') assert lst.size()==4 lst.pop() assert lst.head.datum=='boobies'
def test_pop(): lst= Linked_List() lst.insert(7) lst.insert('Sir Sean Connery') val1= lst.pop() val2= lst.pop() assert val1=='Sir Sean Connery' assert val2==7 assert lst.head is None
def test_pop(): list1 = Linked_List() list1.insert("John") list1.insert("Paul") list1.insert("George") list1.insert("Ringo") popped = list1.pop() assert popped.node_name == "Ringo" assert list1.head.node_name == "George" assert list1.size == 3
class Stack(object): """The stack data structure is a composition of the Linked List structure.""" def __init__(self, iterable=None): """Initialize stack as a Linked_List-esque object.""" self._container = Linked_List(iterable) def push(self, val): """Use Linked List push method to add one Node to stack.""" self._container.push(val) def pop(self): """Use Linked List pop() method to remove one from stack.""" return self._container.pop()
def test_pop(): """Test Linked_List pop method.""" from linked_list import Linked_List test_list = Linked_List() test_list.insert(data[0]) assert test_list.pop().data == data[0]
def test_insert_pop(): b = Linked_List() b.insert(5) assert b.head.data is 5 b.pop() assert b.head is None