コード例 #1
0
    def test_enqueue_different_sizes(self, lst: list) -> None:
        """
        Tests the Queue.enqueue method on queues with different amounts of items.
        """
        q = Queue(lst)
        new_item = randint(-100, 100)

        q.enqueue(new_item)

        self.assertEqual(lst + [new_item], q.get_items())
コード例 #2
0
 def test_enqueue_empty(self) -> None:
     """
     Tests the Queue.enqueue method on empty queues.
     """
     n = 0
     while n <= 10:
         q = Queue()
         queue_item = randint(-100, 100)
         q.enqueue(queue_item)
         self.assertEqual([queue_item], q.get_items())
         n += 1
コード例 #3
0
 def test_enqueue_size_one(self) -> None:
     """
     Tests the Queue.enqueue method on queues with 1 item only.
     """
     n = 0
     while n <= 10:
         initial_item = randint(-1000, 1000)
         q = Queue([initial_item])
         new_item = randint(-1000, 1000)
         q.enqueue(new_item)
         self.assertEqual([initial_item, new_item], q.get_items())
         n += 1