gem5  v22.1.0.0
Functions
circular_queue.test.cc File Reference
#include <gtest/gtest.h>
#include "base/circular_queue.hh"

Go to the source code of this file.

Functions

 TEST (CircularQueueTest, Empty)
 Testing that once instantiated with a fixed size, the queue is still empty. More...
 
 TEST (CircularQueueTest, HeadTailEmpty)
 Testing that once instantiated with a fixed size, the queue has Head = Tail + 1. More...
 
 TEST (CircularQueueTest, AddingElements)
 Adding elements to the circular queue. More...
 
 TEST (CircularQueueTest, RemovingElements)
 Removing elements from the circular queue. More...
 
 TEST (CircularQueueTest, Full)
 Testing CircularQueue::full This tests adds elements to the queue and checks that it is full, which means: More...
 
 TEST (CircularQueueTest, BeginEnd)
 Testing CircularQueue::begin(), CircularQueue::end() This tests the following: More...
 
 TEST (CircularQueueTest, BeginFrontEndBack)
 Testing that begin() and end() (-1) iterators actually point to the correct values so that dereferencing them leads to a match with the values of (front() and back()) More...
 
 TEST (CircularQueueTest, IteratorsOp)
 Testing circular queue iterators: By allocating two iterators to a queue we test several operators. More...
 
 TEST (CircularQueueTest, FullLoop)
 Testing a full loop, which is incrementing one iterator until it wraps and has the same index as the starting iterator. More...
 
 TEST (CircularQueueTest, MultipleRound)
 Testing correct behaviour when rounding multiple times: More...
 

Function Documentation

◆ TEST() [1/10]

TEST ( CircularQueueTest  ,
AddingElements   
)

Adding elements to the circular queue.

Once an element has been added we test the new value of front() and back() (head an tail). Since we are just adding elements and not removing them, we expect the front value to be fixed and the back value to change, matching the latest pushed value.

Definition at line 71 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::back(), gem5::CircularQueue< T >::front(), gem5::CircularQueue< T >::push_back(), and gem5::CircularQueue< T >::size().

◆ TEST() [2/10]

TEST ( CircularQueueTest  ,
BeginEnd   
)

Testing CircularQueue::begin(), CircularQueue::end() This tests the following:

  • In an empty queue, begin() == end()
  • After pushing some elements in the queue, the begin() and end() iterators are correctly misaligned

Definition at line 149 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::begin(), gem5::CircularQueue< T >::end(), and gem5::CircularQueue< T >::push_back().

◆ TEST() [3/10]

TEST ( CircularQueueTest  ,
BeginFrontEndBack   
)

Testing that begin() and end() (-1) iterators actually point to the correct values so that dereferencing them leads to a match with the values of (front() and back())

Definition at line 172 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::back(), gem5::CircularQueue< T >::begin(), gem5::CircularQueue< T >::end(), gem5::CircularQueue< T >::front(), and gem5::CircularQueue< T >::push_back().

◆ TEST() [4/10]

TEST ( CircularQueueTest  ,
Empty   
)

Testing that once instantiated with a fixed size, the queue is still empty.

Definition at line 46 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::capacity(), gem5::CircularQueue< T >::empty(), and gem5::CircularQueue< T >::size().

◆ TEST() [5/10]

TEST ( CircularQueueTest  ,
Full   
)

Testing CircularQueue::full This tests adds elements to the queue and checks that it is full, which means:

  • CircularQueue::full == true
  • Head = Tail + 1

Definition at line 129 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::full(), gem5::CircularQueue< T >::head(), gem5::CircularQueue< T >::push_back(), and gem5::CircularQueue< T >::tail().

◆ TEST() [6/10]

TEST ( CircularQueueTest  ,
FullLoop   
)

Testing a full loop, which is incrementing one iterator until it wraps and has the same index as the starting iterator.

This test checks that even if they have the same index, they are not the same iterator since they have different round.

Definition at line 232 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::begin().

◆ TEST() [7/10]

TEST ( CircularQueueTest  ,
HeadTailEmpty   
)

Testing that once instantiated with a fixed size, the queue has Head = Tail + 1.

Definition at line 58 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::head(), and gem5::CircularQueue< T >::tail().

◆ TEST() [8/10]

TEST ( CircularQueueTest  ,
IteratorsOp   
)

Testing circular queue iterators: By allocating two iterators to a queue we test several operators.

Definition at line 191 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::begin(), and gem5::CircularQueue< T >::push_back().

◆ TEST() [9/10]

TEST ( CircularQueueTest  ,
MultipleRound   
)

Testing correct behaviour when rounding multiple times:

  • Round indexes in sync
  • Difference between begin() and end() iterator is still equal to the CircularQueue size.

Definition at line 252 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::begin(), gem5::CircularQueue< T >::end(), and gem5::CircularQueue< T >::push_back().

◆ TEST() [10/10]

TEST ( CircularQueueTest  ,
RemovingElements   
)

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

Definition at line 94 of file circular_queue.test.cc.

References gem5::CircularQueue< T >::empty(), gem5::CircularQueue< T >::head(), gem5::CircularQueue< T >::pop_front(), gem5::CircularQueue< T >::push_back(), gem5::CircularQueue< T >::size(), and gem5::CircularQueue< T >::tail().


Generated on Wed Dec 21 2022 10:22:53 for gem5 by doxygen 1.9.1