src/base/circular_queue.test.cc
/** Removing elements from the circular queue.
 * We add two elements and we consequently remove them.
 * After removing them we check that the elements have been
 * effectively removed, which means the circular queue is
 * empty */
Removing elements from the circular queue.
We add two elements and we consequently remove them.
After removing them we check that the elements have been
effectively removed, which means the circular queue is
empty
Removing elements from the circular queue . We add two elements and we consequently remove them . After removing them we check that the elements have been effectively removed which means the circular queue is empty
TEST(CircularQueueTest, RemovingElements)
{
    const auto cq_size = 8;
    CircularQueue<uint32_t> cq(cq_size);
    const auto first_element = 0xAAAAAAAA;
    cq.push_back(first_element);
    const auto second_element = 0x55555555;
    cq.push_back(second_element);
    auto initial_head = cq.head();
    auto initial_tail = cq.tail();
    cq.pop_front();
    ASSERT_EQ(cq.head(), initial_head + 1);
    ASSERT_EQ(cq.tail(), initial_tail);
    cq.pop_front();
    ASSERT_EQ(cq.head(), initial_head + 2);
    ASSERT_EQ(cq.tail(), initial_tail);
    ASSERT_EQ(cq.size(), 0);
    ASSERT_TRUE(cq.empty());
}
TEST ( CircularQueueTest , RemovingElements ) { const auto cq_size = 8 ; CircularQueue < uint32_t > cq ( cq_size ) ; const auto first_element = 0xAAAAAAAA ; cq . push_back ( first_element ) ; const auto second_element = 0x55555555 ; cq . push_back ( second_element ) ; auto initial_head = cq . head ( ) ; auto initial_tail = cq . tail ( ) ; cq . pop_front ( ) ; ASSERT_EQ ( cq . head ( ) , initial_head + 1 ) ; ASSERT_EQ ( cq . tail ( ) , initial_tail ) ; cq . pop_front ( ) ; ASSERT_EQ ( cq . head ( ) , initial_head + 2 ) ; ASSERT_EQ ( cq . tail ( ) , initial_tail ) ; ASSERT_EQ ( cq . size ( ) , 0 ) ; ASSERT_TRUE ( cq . empty ( ) ) ; }
Removing elements from the circular queue.
Removing elements from the circular queue .
// Adding first element // Adding second element // Removing first and second element