Exemplo n.º 1
0
 def test(self):
     q=Queue()
     self.assertEqual(len(q),0)
     
     q.enqueue(3)
     self.assertEqual(q.front(),3)
     self.assertEqual(len(q),1)
     
     q.enqueue(2)
     q.enqueue(7)
     q.enqueue(2)
     self.assertEqual(q.front(),3)
     self.assertEqual(len(q),4)
         
     self.assertEqual(q.dequeue(),3)
     self.assertEqual(q.dequeue(),2)
     self.assertEqual(len(q),2)
Exemplo n.º 2
0
def test_size_of_empty_queue():
    q = Queue()
    assert q.size() == 0
Exemplo n.º 3
0
def test_queue_with_no_elements_is_empty():
    q = Queue()
    assert q.is_empty()
Exemplo n.º 4
0
def initialize_queue(*entries):
    q = Queue()
    for entry in entries:
        q.push(entry)
    return q