cnorxz/src/tests/range_unit_test.cc

70 lines
1.1 KiB
C++
Raw Normal View History

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);
EXPECT_TRUE(crx->begin() != crx->end());
EXPECT_FALSE(crx->begin() == crx->end());
EXPECT_EQ(crx->begin().pos(), 0u);
2022-09-18 00:49:36 +02:00
EXPECT_EQ(crx->end().pos(), mSize);
EXPECT_TRUE(cr->begin() != cr->end());
EXPECT_FALSE(cr->begin() == cr->end());
EXPECT_EQ(cr->begin().pos(), 0u);
EXPECT_EQ(cr->end().pos(), mSize);
2022-09-18 00:49:36 +02:00
SizeT cnt = 0;
auto endxi = cr->end();
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();
}