def test_dequeue_when_full(): q = Queue() q.enqueue("apples") q.enqueue("bananas") actual = q.dequeue() expected = "apples" assert actual == expected
def test_enqueue_two(): q = Queue() q.enqueue("apples") q.enqueue("bananas") actual = q.peek() expected = "apples" assert actual == expected
def queue_vals(): queue = Queue() queue.enqueue(8) queue.enqueue('hi') queue.enqueue(-4) queue.enqueue(6) return queue
def test_enqueue(queue_vals): # no nodes q = Queue() assert q.front == None assert q.rear == None # only one node q.enqueue(5) assert q.front.value == 5 assert q.rear.value == 5 # two nodes q.enqueue(7) assert q.front.value == 5 assert q.rear.value == 7 assert queue_vals.rear.value == 6 assert queue_vals.front.value == 8
def test_peek(): q = Queue() q.enqueue("apple") q.enqueue("banana") q.enqueue("cucumber") actual = q.peek() expected = "apple" assert actual == expected
def test_peek_post_dequeue(): # TODO it should return a new first value if peek is called after a dequeue q = Queue() q.enqueue("apples") q.enqueue("bananas") q.enqueue("grapes") q.dequeue() actual = q.peek() expected = "bananas" assert actual == expected
def test_exhausted(): # TODO TODO is empty should return true after dequeueing all previously queued items q = Queue() q.enqueue("apples") q.enqueue("bananas") q.enqueue("grapes") q.dequeue() q.dequeue() q.dequeue() actual = q.is_empty() expected = True assert actual == expected
def test_enqueue(): q = Queue() q.enqueue("apple") actual = q.front.value expected = "apple" assert actual == expected