diff --git a/src/include/ranges/wrange.cc.h b/src/include/ranges/wrange.cc.h index db7e84d..f85da66 100644 --- a/src/include/ranges/wrange.cc.h +++ b/src/include/ranges/wrange.cc.h @@ -311,6 +311,18 @@ namespace CNORXZ return mSpace.data(); } + template + const SizeT* WRange::spaceToPos() const + { + return mSpaceToPos.data(); + } + + template + const SizeT* WRange::posToSpace() const + { + return mPosToSpace.data(); + } + template SizeT WRange::getMeta(const MetaT& meta) const { diff --git a/src/tests/range_unit_test.cc b/src/tests/range_unit_test.cc index 4a56139..ba0ded2 100644 --- a/src/tests/range_unit_test.cc +++ b/src/tests/range_unit_test.cc @@ -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(mMeta).create(); + } + + Vector 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>(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>>(mr);