def test_1(): q = Queue() assert q.empty() q.push(1) assert q.peek() == 1 q.push(2) assert q.peek() == 1 q.push(3) q.push(4) q.pop() q.pop() q.pop() assert q.peek() == 4 q.pop() assert q.empty()
#!/usr/bin/env python # -*- coding: utf-8 -*- from solution import Queue sol = Queue() sol.push(4) print(sol.pop()) print(sol.empty()) # print(sol.peek())
def test_solution(): from solution import Queue queue = Queue() queue.enqueue(1) queue.enqueue(2) queue.enqueue(3) retqueue = Queue() retqueue.enqueue(3) retqueue.enqueue(2) retqueue.enqueue(1) queue2 = Queue() queue2.enqueue(1) queue3 = Queue() assert queue.reverse_queue() == None assert queue == retqueue assert queue2.reverse_queue() == None assert queue2 == queue2 assert queue3.reverse_queue() == None assert queue3 == queue3
def test_dequeue(self): q = Queue() q.enqueue(1) q.enqueue(2) q.enqueue(3) self.assertEqual([1], [q.dequeue()]) q.enqueue(4) q.enqueue(5) q.enqueue(6) self.assertEqual( [2, 3, 4, 5, 6], [q.dequeue(), q.dequeue(), q.dequeue(), q.dequeue(), q.dequeue()])