def test_append(): ll = LinkList() ll.insert('2') ll.insert('3') ll.insert('1') ll.append('5') expected = '1,3,2,5' actual = ll.toStr() assert expected == actual
class Queue(): def __init__(self): self._data = LinkList() def count(self) -> int: return self._data.count() def toStr(self) -> str: return self._data.toStr() def enqueue(self, val) -> bool: # Add a value to the queue return self._data.append(val) def dequeue(self, val) -> bool: # Remove entry from queue with a given value # NOTE: will only remove the first element found with val return self._data.remove(val) def peek(self) -> [bool, object]: # Get value from the head of the queue (without removing it) return self._data.peekHead()
def test_ll_merge(): # @TODO: TEST: Merge two unequal # @TODO: TEST: Merge one empty list # @TODO: TEST: Merge two empty lists # @TODO: TEST: Merge a list with just 1 item listA = LinkList() listA.append('apple') listA.append('bannana') listA.append('orange') listB = LinkList() listB.append('cheerios') listB.append('frosted flakes') listB.append('wheaties') listA.mergeList(listA, listB) expected = 'apple,cheerios,bannana,frosted flakes,orange,wheaties' actual = listA.toStr() assert expected == actual