start a type tuple unit test...
This commit is contained in:
parent
1620b8dcef
commit
95f0b26e38
6 changed files with 137 additions and 16 deletions
|
|
@ -36,6 +36,7 @@
|
|||
** might come in handy.
|
||||
**
|
||||
** @see control::CommandDef usage example
|
||||
** @see tuple-test.cpp
|
||||
** @see typelist.hpp
|
||||
** @see function.hpp
|
||||
** @see generator.hpp
|
||||
|
|
|
|||
|
|
@ -550,6 +550,11 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "TypeTuple_test" TypeTuple_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
TEST "VectorTransfer_test" VectorTransfer_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ test_lib_SOURCES = \
|
|||
$(testlib_srcdir)/mainsuite.cpp \
|
||||
$(testlib_srcdir)/meta/typelist-test.cpp \
|
||||
$(testlib_srcdir)/meta/typelist-manip-test.cpp \
|
||||
$(testlib_srcdir)/meta/type-tuple-test.cpp \
|
||||
$(testlib_srcdir)/meta/function-closure-test.cpp \
|
||||
$(testlib_srcdir)/meta/function-erasure-test.cpp \
|
||||
$(testlib_srcdir)/meta/generator-test.cpp \
|
||||
|
|
|
|||
102
tests/lib/meta/type-tuple-test.cpp
Normal file
102
tests/lib/meta/type-tuple-test.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
TypeTuple(Test) - checking type tuples and records based on them
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2009, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
/** @file type-tuple-test.cpp
|
||||
** Interconnection of typelists, type tuples and simple record
|
||||
** data types build on top of them.
|
||||
** @todo define function-closure-test
|
||||
**
|
||||
** @see lumiera::typelist::Tuple
|
||||
** @see tuple.hpp
|
||||
** @see function-closure.hpp
|
||||
** @see control::CmdClosure real world usage example
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "lib/meta/typelist.hpp" ////////////TODO really?
|
||||
#include "lib/meta/tuple.hpp"
|
||||
#include "meta/typelist-diagnostics.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
//#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using ::test::Test;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
|
||||
|
||||
namespace lumiera {
|
||||
namespace typelist{
|
||||
namespace test {
|
||||
|
||||
|
||||
namespace { // test data
|
||||
|
||||
|
||||
|
||||
typedef Types< Num<1>
|
||||
, Num<2>
|
||||
, Num<3>
|
||||
>::List List1;
|
||||
typedef Types< Num<5>
|
||||
, Num<6>
|
||||
, Num<7>
|
||||
>::List List2;
|
||||
|
||||
|
||||
template<class X> struct CountDown { typedef NullType List; };
|
||||
template<> struct CountDown<Num<0> > { typedef Node<Num<0>, NullType> List; };
|
||||
template<int I> struct CountDown<Num<I> > { typedef Node<Num<I>, typename CountDown<Num<I-1> >::List> List; };
|
||||
|
||||
|
||||
|
||||
} // (End) test data
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* @test //////////////////////////////////////////
|
||||
* - building combinations and permutations
|
||||
*/
|
||||
class TypeTuple_test : public Test
|
||||
{
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
UNIMPLEMENTED ("verify type tuples");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (TypeTuple_test, "unit common");
|
||||
|
||||
|
||||
|
||||
}}} // namespace lumiera::typelist::test
|
||||
|
|
@ -36,6 +36,7 @@
|
|||
#define META_TYPELIST_DIAGNOSTICS_H
|
||||
|
||||
|
||||
#include "lib/meta/typelist.hpp"
|
||||
#include "lib/meta/generator.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
|
@ -68,9 +69,16 @@ namespace typelist{
|
|||
struct Config;
|
||||
|
||||
|
||||
|
||||
/** helper for generating test lists */
|
||||
template<class X> struct CountDown { typedef NullType List; };
|
||||
template<> struct CountDown<Num<0> > { typedef Node<Num<0>, NullType> List; };
|
||||
template<int I> struct CountDown<Num<I> > { typedef Node<Num<I>, typename CountDown<Num<I-1> >::List> List; };
|
||||
|
||||
namespace test {
|
||||
namespace { // hidden internals
|
||||
|
||||
|
||||
namespace test { //< unit tests covering typelist manipulating templates
|
||||
namespace { // hidden internals for diagnostics....
|
||||
|
||||
using boost::format;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
#include "lib/meta/generator.hpp"
|
||||
#include "lib/meta/typelistutil.hpp"
|
||||
#include "meta/typelist-diagnostics.hpp"
|
||||
#include "lib/util.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <iostream>
|
||||
|
|
@ -71,11 +71,7 @@ namespace test {
|
|||
>::List List2;
|
||||
|
||||
|
||||
template<class X> struct CountDown { typedef NullType List; };
|
||||
template<> struct CountDown<Num<0> > { typedef Node<Num<0>, NullType> List; };
|
||||
template<int I> struct CountDown<Num<I> > { typedef Node<Num<I>, typename CountDown<Num<I-1> >::List> List; };
|
||||
|
||||
|
||||
// see also the CountDown template in typelist-diagnostics.hpp...
|
||||
|
||||
} // (End) test data
|
||||
|
||||
|
|
@ -96,7 +92,8 @@ namespace test {
|
|||
*/
|
||||
class TypeListManipl_test : public Test
|
||||
{
|
||||
virtual void run(Arg arg)
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
check_diagnostics ();
|
||||
check_apply ();
|
||||
|
|
@ -108,7 +105,8 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
void check_diagnostics ()
|
||||
void
|
||||
check_diagnostics ()
|
||||
{
|
||||
// Explanation: the DISPLAY macro expands as follows....
|
||||
typedef InstantiateChained<List1::List, Printer, NullP > Contents_List1;
|
||||
|
|
@ -123,7 +121,8 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
void check_append ()
|
||||
void
|
||||
check_append ()
|
||||
{
|
||||
typedef Append<NullType, NullType> Append1;
|
||||
DISPLAY (Append1);
|
||||
|
|
@ -156,7 +155,8 @@ namespace test {
|
|||
template<class X> struct AddConst2 { typedef X Type; };
|
||||
template<int I> struct AddConst2<Num<I> > { typedef Num<I+2> Type; };
|
||||
|
||||
void check_apply ()
|
||||
void
|
||||
check_apply ()
|
||||
{
|
||||
typedef Apply<List1, AddConst2> Added2;
|
||||
DISPLAY (Added2);
|
||||
|
|
@ -166,14 +166,16 @@ namespace test {
|
|||
template<class X> struct IsEven { enum {value = false }; };
|
||||
template<int I> struct IsEven<Num<I> > { enum {value = (0 == I % 2) }; };
|
||||
|
||||
void check_filter ()
|
||||
void
|
||||
check_filter ()
|
||||
{
|
||||
typedef Filter<Append<List1,List2>::List, IsEven > FilterEven;
|
||||
DISPLAY (FilterEven);
|
||||
}
|
||||
|
||||
|
||||
void check_prefix ()
|
||||
void
|
||||
check_prefix ()
|
||||
{
|
||||
typedef PrefixAll<Num<11>,Num<22> > Prefix1;
|
||||
DISPLAY (Prefix1);
|
||||
|
|
@ -196,7 +198,8 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
void check_distribute()
|
||||
void
|
||||
check_distribute()
|
||||
{
|
||||
typedef Distribute<Num<11>, List1> Dist1;
|
||||
DISPLAY (Dist1);
|
||||
|
|
@ -213,7 +216,8 @@ namespace test {
|
|||
}
|
||||
|
||||
|
||||
void check_combine()
|
||||
void
|
||||
check_combine()
|
||||
{
|
||||
typedef CountDown<Num<11> > Down;
|
||||
DISPLAY (Down);
|
||||
|
|
|
|||
Loading…
Reference in a new issue