2022-09-15 16:45:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
//#include "cnorxz.h"
|
|
|
|
#include "ranges/ranges.h"
|
|
|
|
|
2022-09-28 19:09:45 +02:00
|
|
|
namespace
|
|
|
|
{
|
2022-09-15 16:45:45 +02:00
|
|
|
|
|
|
|
using namespace CNORXZ;
|
|
|
|
|
|
|
|
class CR_Test : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
|
|
|
CR_Test()
|
|
|
|
{
|
|
|
|
mSize = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
SizeT mSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(CR_Test, Basics)
|
|
|
|
{
|
|
|
|
auto cr = CRangeFactory(mSize).create();
|
2022-09-18 00:49:36 +02:00
|
|
|
auto crx = std::dynamic_pointer_cast<CRange>(cr);
|
2022-09-15 16:45:45 +02:00
|
|
|
EXPECT_EQ(cr->size(), mSize);
|
2022-09-18 00:49:36 +02:00
|
|
|
EXPECT_EQ(crx->size(), mSize);
|
|
|
|
|
2022-09-28 23:28:07 +02:00
|
|
|
EXPECT_TRUE(crx->begin() != crx->end());
|
|
|
|
EXPECT_FALSE(crx->begin() == crx->end());
|
2022-09-18 17:04:25 +02:00
|
|
|
EXPECT_EQ(crx->begin().pos(), 0u);
|
2022-09-18 00:49:36 +02:00
|
|
|
EXPECT_EQ(crx->end().pos(), mSize);
|
|
|
|
|
2022-09-28 23:28:07 +02:00
|
|
|
EXPECT_TRUE(cr->begin() != cr->end());
|
|
|
|
EXPECT_FALSE(cr->begin() == cr->end());
|
2022-09-18 17:04:25 +02:00
|
|
|
EXPECT_EQ(cr->begin().pos(), 0u);
|
2022-09-18 16:19:27 +02:00
|
|
|
EXPECT_EQ(cr->end().pos(), mSize);
|
2022-09-18 00:49:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
SizeT cnt = 0;
|
|
|
|
auto endxi = cr->end();
|
2022-09-18 16:19:27 +02:00
|
|
|
for(auto xi = cr->begin(); xi != endxi; ++xi){
|
|
|
|
EXPECT_EQ(xi.pos(), cnt);
|
|
|
|
EXPECT_EQ(*xi, cnt);
|
2022-09-18 00:49:36 +02:00
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
SizeT cnt2 = 0;
|
|
|
|
for(auto x: *crx){
|
|
|
|
EXPECT_EQ(x, cnt2++);
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:45:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UR_Test
|
|
|
|
// RCast_Test
|
|
|
|
}
|
2022-09-18 00:49:36 +02:00
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|