start implementing index unit test
This commit is contained in:
parent
c31eb76981
commit
230ca490d5
6 changed files with 106 additions and 39 deletions
|
@ -49,42 +49,59 @@ namespace MultiArrayTools
|
||||||
enum class RangeType;
|
enum class RangeType;
|
||||||
|
|
||||||
// range_base.h
|
// range_base.h
|
||||||
class MultiRangeType;
|
|
||||||
|
|
||||||
// range_base.h
|
|
||||||
class IndefinitRangeBase;
|
|
||||||
|
|
||||||
// range_base.h
|
|
||||||
template <class Index>
|
|
||||||
class RangeBase;
|
class RangeBase;
|
||||||
|
|
||||||
|
// range_base.h
|
||||||
|
class RangeFactoryBase;
|
||||||
|
|
||||||
// range_base.h
|
// range_base.h
|
||||||
template <class Index>
|
template <class Index>
|
||||||
class SubRangeBase;
|
class RangeInterface;
|
||||||
|
|
||||||
// index_base.h
|
// index_base.h
|
||||||
class IndefinitIndexBase;
|
|
||||||
|
|
||||||
// index_base.h
|
|
||||||
template <class Index>
|
|
||||||
class IndexBase;
|
class IndexBase;
|
||||||
|
|
||||||
// single_range.h
|
// index_base.h
|
||||||
template <typename U, RangeType TYPE>
|
template <typename MetaType>
|
||||||
class SingleIndex;
|
class IndexInterface;
|
||||||
|
|
||||||
// single_range.h
|
// single_range.h
|
||||||
template <typename U, RangeType TYPE>
|
template <typename U, RangeType TYPE>
|
||||||
class SingleRange;
|
class SingleRange;
|
||||||
|
|
||||||
// multi_range.h
|
// single_range.h
|
||||||
template <class... Indices>
|
template <typename U, RangeType TYPE>
|
||||||
class MultiIndex;
|
class SingleRangeFactory;
|
||||||
|
|
||||||
|
// single_range.h
|
||||||
|
template <typename U>
|
||||||
|
class SingleIndex;
|
||||||
|
|
||||||
|
// multi_range.h
|
||||||
|
template <class... Ranges>
|
||||||
|
class MultiRangeFactory;
|
||||||
|
|
||||||
// multi_range.h
|
// multi_range.h
|
||||||
template <class... Ranges>
|
template <class... Ranges>
|
||||||
class MultiRange;
|
class MultiRange;
|
||||||
|
|
||||||
|
// multi_range.h
|
||||||
|
template <class... Indices>
|
||||||
|
class MultiIndex;
|
||||||
|
|
||||||
|
// container_range.h
|
||||||
|
template <class... Ranges>
|
||||||
|
class ContainerRangeFactory;
|
||||||
|
|
||||||
|
// container_range.h
|
||||||
|
template <class... Ranges>
|
||||||
|
class ContainerRange;
|
||||||
|
|
||||||
|
// container_range.h
|
||||||
|
template <class... Indices>
|
||||||
|
class ContainerIndex;
|
||||||
|
|
||||||
|
/*
|
||||||
// multi_array.h
|
// multi_array.h
|
||||||
template <typename T, class Range>
|
template <typename T, class Range>
|
||||||
class MultiArrayBase;
|
class MultiArrayBase;
|
||||||
|
@ -153,6 +170,7 @@ namespace MultiArrayTools
|
||||||
|
|
||||||
// ma_functional.h
|
// ma_functional.h
|
||||||
class pyProjNoSymFunction;
|
class pyProjNoSymFunction;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
typedef ContainerRange<Ranges...> oType;
|
||||||
|
|
||||||
ContainerRangeFactory() = delete;
|
ContainerRangeFactory() = delete;
|
||||||
ContainerRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
ContainerRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
||||||
ContainerRangeFactory(const ContainerRange<Ranges...>::SpaceType& space);
|
ContainerRangeFactory(const ContainerRange<Ranges...>::SpaceType& space);
|
||||||
|
|
|
@ -10,37 +10,52 @@ namespace MAT = MultiArrayTools;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using namespace MAT;
|
||||||
|
|
||||||
class ConnectionTest : public ::testing::Test
|
class ConnectionTest : public ::testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef MAT::SingleRange<char,MAT::RangeType::ANY> SingleRc;
|
typedef SingleRangeFactory<char,RangeType::ANY> SRF;
|
||||||
typedef MAT::SingleRange<int,MAT::RangeType::ANY> SingleRi;
|
typedef SRF::oType SRange;
|
||||||
typedef MAT::MultiRange<SingleRc,SingleRc,SingleRi> MultiR3d;
|
|
||||||
typedef MAT::MultiRange<SingleRi,SingleRc> MultiR2d;
|
|
||||||
|
|
||||||
ConnectionTest() : sri1({0,1,2,3}),
|
typedef MultiRangeFactory<SRange,SRange,SRange> M3RF;
|
||||||
src1({'a','b'}),
|
typedef M3RF::oType M3Range;
|
||||||
src2({'a','b','c'}),
|
|
||||||
mr3d1(src1,src2,sri1) {}
|
typedef MultiRangeFactory<SRange,M3Range,SRange> MasterRF;
|
||||||
|
typedef MasterRF::oType MasterRange;
|
||||||
SingleRi sri1;
|
|
||||||
SingleRc src1;
|
typedef ContainerRangeFactory<M3Range,SRange> CRF;
|
||||||
SingleRc src2;
|
typedef CRF::oType CRange;
|
||||||
MultiR3d mr3d1;
|
|
||||||
|
ConnectionTest()
|
||||||
|
{
|
||||||
|
rfbptr.swap( std::make_shared<SRF>( { 'e', 'b', 'n' } ) );
|
||||||
|
sr1ptr = std::dynamic_pointer_cast<SRange>( rfbptr.create() );
|
||||||
|
|
||||||
|
rfbptr.swap( std::make_shared<SRF>( { 'x', 'y', 'l', 'f' } ) );
|
||||||
|
sr2ptr = std::dynamic_pointer_cast<SRange>( rfbptr.create() );
|
||||||
|
|
||||||
|
rfbptr.swap( std::make_shared<SRF>( { 'a', 'b' } ) );
|
||||||
|
std::shared_ptr<SRange> temp1 = std::dynamic_pointer_cast<SRange>( rfbptr.create() );
|
||||||
|
rfbptr.swap( std::make_shared<SRF>( { '1' } ) );
|
||||||
|
std::shared_ptr<SRange> temp2 = std::dynamic_pointer_cast<SRange>( rfbptr.create() );
|
||||||
|
rfbptr.swap( std::make_shared<SRF>( { '0', '7' } ) );
|
||||||
|
std::shared_ptr<SRange> temp3 = std::dynamic_pointer_cast<SRange>( rfbptr.create() );
|
||||||
|
|
||||||
|
rfbptr.swap( std::make_shared<M3RF>( temp1, temp2, temp3 ) );
|
||||||
|
m3rptr = std::dynamic_pointer_cast<M3Range>( rfbptr.create() );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<RangeFactoryBase> rfbptr;
|
||||||
|
std::shared_ptr<SRange> sr1ptr;
|
||||||
|
std::shared_ptr<SRange> sr2ptr;
|
||||||
|
std::shared_ptr<M3Range> m3rptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ConnectionTest, UnlinkedIteration)
|
TEST_F(ConnectionTest, UnlinkedIteration)
|
||||||
{
|
{
|
||||||
auto i3d = mr3d1.begin();
|
|
||||||
auto& ii1 = i3d.template getIndex<2>();
|
|
||||||
EXPECT_EQ(i3d.pos(), 0);
|
EXPECT_EQ(i3d.pos(), 0);
|
||||||
++ii1;
|
|
||||||
EXPECT_EQ(i3d.pos(), 1);
|
|
||||||
++ii1;
|
|
||||||
EXPECT_EQ(i3d.pos(), 2);
|
|
||||||
++ii1;
|
|
||||||
EXPECT_EQ(i3d.pos(), 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
|
@ -68,6 +68,8 @@ namespace MultiArrayTools
|
||||||
class MultiRangeFactory : public RangeFactoryBase
|
class MultiRangeFactory : public RangeFactoryBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef MultiRange<Ranges...> oType;
|
||||||
|
|
||||||
MultiRangeFactory() = delete;
|
MultiRangeFactory() = delete;
|
||||||
MultiRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
MultiRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
||||||
MultiRangeFactory(const MultiRange<Ranges...>::SpaceType& space);
|
MultiRangeFactory(const MultiRange<Ranges...>::SpaceType& space);
|
||||||
|
|
|
@ -63,6 +63,23 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
return mPos == 0;
|
return mPos == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************
|
||||||
|
* SingleRange *
|
||||||
|
********************/
|
||||||
|
|
||||||
|
template <typename U, RangeType TYPE>
|
||||||
|
SingleRangeFactory<U,TYPE>::SingleRangeFactory(const std::vector<U>& space)
|
||||||
|
{
|
||||||
|
mProd = std::make_shared<oType>( space );
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U, RangeType TYPE>
|
||||||
|
std::shared_ptr<RangeBase> SingleRangeFactory<U,TYPE>::create()
|
||||||
|
{
|
||||||
|
setSelf();
|
||||||
|
return mProd;
|
||||||
|
}
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* SingleRange *
|
* SingleRange *
|
||||||
|
|
|
@ -35,6 +35,19 @@ namespace MultiArrayTools
|
||||||
virtual bool first() const override;
|
virtual bool first() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, RangeType TYPE>
|
||||||
|
class SingleRangeFactory : public RangeFactoryBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef SingleRange<U,TYPE> oType;
|
||||||
|
|
||||||
|
SingleRangeFactory() = delete;
|
||||||
|
SingleRangeFactory(const std::vector<U>& space);
|
||||||
|
std::shared_ptr<RangeBase> create();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
template <typename U, RangeType TYPE>
|
template <typename U, RangeType TYPE>
|
||||||
class SingleRange : public RangeInterface<SingleIndex<U> >
|
class SingleRange : public RangeInterface<SingleIndex<U> >
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue