def test_SpecifyThatAnItemCanBeInserted(self): # arrange priorityQueue = PriorityQueue() # act priorityQueue.Insert(4) # assert self.assertEqual(priorityQueue.IsEmpty(), False) self.assertEqual(priorityQueue._items[0], 4)
def test_SpecifyThatFirstItemInQueueCanBeSeen(self): # arrange priorityQueue = PriorityQueue() # act priorityQueue.Insert(4) priorityQueue.Insert(5) priorityQueue.Insert(8) priorityQueue.Insert(1) priorityQueue.Insert(3) # assert self.assertEqual(priorityQueue.IsEmpty(), False) self.assertEqual(len(priorityQueue._items), 5) self.assertEqual(priorityQueue.Peek(), 1)
def test_SpecifyThatFirstItemCanBeRetrievedFromTheQueue(self): # arrange priorityQueue = PriorityQueue() # act priorityQueue.Insert(4) priorityQueue.Insert(5) priorityQueue.Insert(8) priorityQueue.Insert(1) priorityQueue.Insert(3) # assert self.assertEqual(priorityQueue.IsEmpty(), False) self.assertEqual(len(priorityQueue._items), 5) self.assertEqual(priorityQueue.Pop(), 1) self.assertEqual(len(priorityQueue._items), 4)
def test_SpecifyThatPriorityDoesNotContainDuplicates(self): # arrange priorityQueue = PriorityQueue() # act priorityQueue.Insert(4) priorityQueue.Insert(3) priorityQueue.Insert(4) priorityQueue.Insert(1) priorityQueue.Insert(3) # assert self.assertEqual(priorityQueue.IsEmpty(), False) self.assertEqual(len(priorityQueue._items), 3) self.assertEqual(priorityQueue._items[0], 4) self.assertEqual(priorityQueue._items[1], 3) self.assertEqual(priorityQueue._items[2], 1)
def test_SpecifyThatMultipleItemsCanBeInsertedAndOrdered(self): # arrange priorityQueue = PriorityQueue() # act priorityQueue.Insert(4) priorityQueue.Insert(5) priorityQueue.Insert(8) priorityQueue.Insert(1) priorityQueue.Insert(3) # assert self.assertEqual(priorityQueue.IsEmpty(), False) self.assertEqual(len(priorityQueue._items), 5) self.assertEqual(priorityQueue._items[0], 8) self.assertEqual(priorityQueue._items[1], 5) self.assertEqual(priorityQueue._items[2], 4) self.assertEqual(priorityQueue._items[3], 3) self.assertEqual(priorityQueue._items[4], 1)
def test_SpecifyThatItCanBeDeterminedIfTheQueueIsEmpty(self): # arrange priorityQueue = PriorityQueue() # assert self.assertEqual(priorityQueue.IsEmpty(), True)