WRange: tests + fixes
This commit is contained in:
parent
e8b6dd9f4d
commit
f6a3ef64cc
2 changed files with 58 additions and 0 deletions
|
@ -311,6 +311,18 @@ namespace CNORXZ
|
|||
return mSpace.data();
|
||||
}
|
||||
|
||||
template <typename MetaT>
|
||||
const SizeT* WRange<MetaT>::spaceToPos() const
|
||||
{
|
||||
return mSpaceToPos.data();
|
||||
}
|
||||
|
||||
template <typename MetaT>
|
||||
const SizeT* WRange<MetaT>::posToSpace() const
|
||||
{
|
||||
return mPosToSpace.data();
|
||||
}
|
||||
|
||||
template <typename MetaT>
|
||||
SizeT WRange<MetaT>::getMeta(const MetaT& meta) const
|
||||
{
|
||||
|
|
|
@ -51,6 +51,20 @@ namespace
|
|||
RangePtr ur;
|
||||
};
|
||||
|
||||
class WR_Test : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
||||
WR_Test()
|
||||
{
|
||||
mMeta = { "These", "are", "test", "strings", "foo", "bar", "baz" };
|
||||
wr = WRangeFactory<String>(mMeta).create();
|
||||
}
|
||||
|
||||
Vector<String> mMeta;
|
||||
RangePtr wr;
|
||||
};
|
||||
|
||||
class MR_Test : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
@ -211,6 +225,38 @@ namespace
|
|||
EXPECT_EQ(prx->orig(),ur);
|
||||
}
|
||||
|
||||
TEST_F(WR_Test, Basics)
|
||||
{
|
||||
auto wrx = std::dynamic_pointer_cast<WRange<String>>(wr);
|
||||
EXPECT_FALSE(wrx == nullptr);
|
||||
EXPECT_EQ(wr->size(), mMeta.size());
|
||||
EXPECT_EQ(wrx->size(), mMeta.size());
|
||||
|
||||
EXPECT_TRUE(wrx->begin() != wrx->end());
|
||||
EXPECT_FALSE(wrx->begin() == wrx->end());
|
||||
EXPECT_EQ(wrx->begin().pos(), 0u);
|
||||
EXPECT_EQ(wrx->end().pos(), mMeta.size());
|
||||
|
||||
EXPECT_TRUE(wr->begin() != wr->end());
|
||||
EXPECT_FALSE(wr->begin() == wr->end());
|
||||
EXPECT_EQ(wr->begin().pos(), 0u);
|
||||
EXPECT_EQ(wr->end().pos(), mMeta.size());
|
||||
|
||||
SizeT cnt = 0;
|
||||
auto endxi = wr->end();
|
||||
for(auto xi = wr->begin(); xi != endxi; ++xi){
|
||||
EXPECT_EQ(xi.pos(), cnt);
|
||||
EXPECT_TRUE(*xi == DType(mMeta[cnt]));
|
||||
EXPECT_EQ((*xi).str(), mMeta[cnt]);
|
||||
++cnt;
|
||||
}
|
||||
|
||||
SizeT cnt2 = 0;
|
||||
for(const auto& x: *wrx){
|
||||
EXPECT_EQ(x, mMeta[cnt2++]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MR_Test, Basics2d)
|
||||
{
|
||||
auto mrx = std::dynamic_pointer_cast<MRange<CRange,URange<String>>>(mr);
|
||||
|
|
Loading…
Reference in a new issue