43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include "precompiled_unittests_core.h"
|
|
|
|
#include "core/container/queue.h"
|
|
|
|
namespace ITF
|
|
{
|
|
|
|
TEST(queue, test_IteratorComparison)
|
|
{
|
|
ITF_QUEUE<int> aQueue;
|
|
ITF_QUEUE<int>::const_iterator itBegin, itEnd;
|
|
|
|
// Empty queue
|
|
itBegin = aQueue.begin();
|
|
itEnd = aQueue.end();
|
|
EXPECT_EQ(itBegin, itEnd);
|
|
EXPECT_LE(itBegin, itEnd);
|
|
EXPECT_GE(itBegin, itEnd);
|
|
|
|
// Queue with 1 element
|
|
aQueue.push(0);
|
|
itBegin = aQueue.begin();
|
|
itEnd = aQueue.end();
|
|
EXPECT_NE(itBegin, itEnd);
|
|
EXPECT_LT(itBegin, itEnd);
|
|
EXPECT_GT(itEnd, itBegin);
|
|
|
|
// Queue with content wrapping at the end of its internal buffer
|
|
aQueue.pop();
|
|
aQueue.push(1);
|
|
aQueue.pop();
|
|
aQueue.push(2);
|
|
aQueue.push(3);
|
|
itBegin = aQueue.begin();
|
|
itEnd = aQueue.end();
|
|
EXPECT_EQ(static_cast<int>(aQueue.size()), 2);
|
|
EXPECT_EQ(static_cast<int>(aQueue.capacity()), 3);
|
|
EXPECT_NE(itBegin, itEnd);
|
|
EXPECT_LT(itBegin, itEnd);
|
|
EXPECT_GT(itEnd, itBegin);
|
|
}
|
|
|
|
}
|