Exemple #1
0
    def test_is_full(self):
        desired_queue_size = 3
        queue = CircularQueue(desired_queue_size)

        for i in range(desired_queue_size):
            assert not queue.is_full
            queue.append(i)

        assert queue.is_full

        for i in range(desired_queue_size):
            queue.pop()
            assert not queue.is_full
Exemple #2
0
    def test_pop(self):
        desired_queue_size = 3
        queue = CircularQueue(desired_queue_size)

        assert queue.pop() is None

        for i in range(desired_queue_size):
            queue.append(i)

        for i in range(desired_queue_size - 1, -1, -1):
            assert queue.pop() == i

        assert queue.pop() is None
Exemple #3
0
    def test_is_empty(self):
        desired_queue_size = 3
        queue = CircularQueue(desired_queue_size)

        assert queue.is_empty

        for i in range(desired_queue_size):
            queue.append(i)
            assert not queue.is_empty

        for i in range(desired_queue_size):
            queue.pop()

        assert queue.is_empty
Exemple #4
0
    def test__len__(self):
        desired_queue_size = 3
        queue = CircularQueue(desired_queue_size)
        assert len(queue) == 0

        for i in range(3):
            queue.append(i)
            assert len(queue) == i + 1

        queue.append(4)
        assert len(queue) == desired_queue_size

        for i in range(3, 0, -1):
            queue.pop()
            assert len(queue) == i - 1