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;
|
||||
|
||||
// range_base.h
|
||||
class MultiRangeType;
|
||||
|
||||
// range_base.h
|
||||
class IndefinitRangeBase;
|
||||
|
||||
// range_base.h
|
||||
template <class Index>
|
||||
class RangeBase;
|
||||
|
||||
// range_base.h
|
||||
class RangeFactoryBase;
|
||||
|
||||
// range_base.h
|
||||
template <class Index>
|
||||
class SubRangeBase;
|
||||
class RangeInterface;
|
||||
|
||||
// index_base.h
|
||||
class IndefinitIndexBase;
|
||||
|
||||
// index_base.h
|
||||
template <class Index>
|
||||
class IndexBase;
|
||||
|
||||
// single_range.h
|
||||
template <typename U, RangeType TYPE>
|
||||
class SingleIndex;
|
||||
// index_base.h
|
||||
template <typename MetaType>
|
||||
class IndexInterface;
|
||||
|
||||
// single_range.h
|
||||
template <typename U, RangeType TYPE>
|
||||
class SingleRange;
|
||||
|
||||
// single_range.h
|
||||
template <typename U, RangeType TYPE>
|
||||
class SingleRangeFactory;
|
||||
|
||||
// single_range.h
|
||||
template <typename U>
|
||||
class SingleIndex;
|
||||
|
||||
// multi_range.h
|
||||
template <class... Indices>
|
||||
class MultiIndex;
|
||||
template <class... Ranges>
|
||||
class MultiRangeFactory;
|
||||
|
||||
// multi_range.h
|
||||
template <class... Ranges>
|
||||
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
|
||||
template <typename T, class Range>
|
||||
class MultiArrayBase;
|
||||
|
@ -153,6 +170,7 @@ namespace MultiArrayTools
|
|||
|
||||
// ma_functional.h
|
||||
class pyProjNoSymFunction;
|
||||
*/
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MultiArrayTools
|
|||
{
|
||||
public:
|
||||
|
||||
typedef ContainerRange<Ranges...> oType;
|
||||
|
||||
ContainerRangeFactory() = delete;
|
||||
ContainerRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
||||
ContainerRangeFactory(const ContainerRange<Ranges...>::SpaceType& space);
|
||||
|
|
|
@ -10,37 +10,52 @@ namespace MAT = MultiArrayTools;
|
|||
|
||||
namespace {
|
||||
|
||||
using namespace MAT;
|
||||
|
||||
class ConnectionTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef MAT::SingleRange<char,MAT::RangeType::ANY> SingleRc;
|
||||
typedef MAT::SingleRange<int,MAT::RangeType::ANY> SingleRi;
|
||||
typedef MAT::MultiRange<SingleRc,SingleRc,SingleRi> MultiR3d;
|
||||
typedef MAT::MultiRange<SingleRi,SingleRc> MultiR2d;
|
||||
typedef SingleRangeFactory<char,RangeType::ANY> SRF;
|
||||
typedef SRF::oType SRange;
|
||||
|
||||
ConnectionTest() : sri1({0,1,2,3}),
|
||||
src1({'a','b'}),
|
||||
src2({'a','b','c'}),
|
||||
mr3d1(src1,src2,sri1) {}
|
||||
typedef MultiRangeFactory<SRange,SRange,SRange> M3RF;
|
||||
typedef M3RF::oType M3Range;
|
||||
|
||||
SingleRi sri1;
|
||||
SingleRc src1;
|
||||
SingleRc src2;
|
||||
MultiR3d mr3d1;
|
||||
typedef MultiRangeFactory<SRange,M3Range,SRange> MasterRF;
|
||||
typedef MasterRF::oType MasterRange;
|
||||
|
||||
typedef ContainerRangeFactory<M3Range,SRange> CRF;
|
||||
typedef CRF::oType CRange;
|
||||
|
||||
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)
|
||||
{
|
||||
auto i3d = mr3d1.begin();
|
||||
auto& ii1 = i3d.template getIndex<2>();
|
||||
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
|
||||
|
|
|
@ -68,6 +68,8 @@ namespace MultiArrayTools
|
|||
class MultiRangeFactory : public RangeFactoryBase
|
||||
{
|
||||
public:
|
||||
typedef MultiRange<Ranges...> oType;
|
||||
|
||||
MultiRangeFactory() = delete;
|
||||
MultiRangeFactory(const std::shared_ptr<Ranges>&... rs);
|
||||
MultiRangeFactory(const MultiRange<Ranges...>::SpaceType& space);
|
||||
|
|
|
@ -64,6 +64,23 @@ namespace MultiArrayTools
|
|||
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 *
|
||||
********************/
|
||||
|
|
|
@ -35,6 +35,19 @@ namespace MultiArrayTools
|
|||
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>
|
||||
class SingleRange : public RangeInterface<SingleIndex<U> >
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue