Example #1
0
    def test_size(self):
        queue = SimpleQueue()
        assert queue.size() == 0

        queue.push(1)
        assert queue.size() == 1

        queue.pop()
        assert queue.size() == 0
Example #2
0
    def test_enqueue(self):
        queue = SimpleQueue()

        tests = [1, '0', SimpleQueue, lambda x: x, {}, [], None]

        for test in tests:
            queue.add(test)

        assert len(tests) == queue.size()
Example #3
0
    def test_dequeue(self):
        queue = SimpleQueue()

        with self.assertRaises(SimpleQueueDequeueException):
            queue.dequeue()

        one = 1
        two = 2

        queue.add(one)
        queue.add(two)

        assert queue.size() == 2

        assert queue.dequeue() == one
        assert queue.dequeue() == two

        assert queue.size() == 0