mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 07:27:23 +01:00
Increased Tuple capacity to 20 parameters; introduced TypeListType; added TypeListTest.cpp/.h
This commit is contained in:
parent
421ada46a8
commit
605736b626
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TypeList.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/TypeList.h#2 $
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/TypeList.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -12,6 +12,10 @@
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Portions extracted and adapted from
|
||||
// The Loki Library
|
||||
// Copyright (c) 2001 by Andrei Alexandrescu
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
@ -47,7 +51,6 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct TypeList;
|
||||
|
||||
@ -140,27 +143,80 @@ struct TypeList
|
||||
};
|
||||
|
||||
|
||||
#define TYPELIST_1(T1) TypeList<T1, NullTypeList>
|
||||
#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2)>
|
||||
#define TYPELIST_3(T1, T2, T3) TypeList<T1, TYPELIST_2(T2, T3)>
|
||||
#define TYPELIST_4(T1, T2, T3, T4) TypeList<T1, TYPELIST_3(T2, T3, T4)>
|
||||
#define TYPELIST_5(T1, T2, T3, T4, T5) TypeList<T1, TYPELIST_4(T2, T3, T4, T5)>
|
||||
#define TYPELIST_6(T1, T2, T3, T4, T5, T6) TypeList<T1, TYPELIST_5(T2, T3, T4, T5, T6)>
|
||||
#define TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) TypeList<T1, TYPELIST_6(T2, T3, T4, T5, T6, T7)>
|
||||
#define TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) TypeList<T1, TYPELIST_7(T2, T3, T4, T5, T6, T7, T8)>
|
||||
#define TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) TypeList<T1, TYPELIST_8(T2, T3, T4, T5, T6, T7, T8, T9)>
|
||||
#define TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
|
||||
TypeList<T1, TYPELIST_9(T2, T3, T4, T5, T6, T7, T8, T9, T10)>
|
||||
#define TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
|
||||
TypeList<T1, TYPELIST_10(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
|
||||
#define TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
|
||||
TypeList<T1, TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
|
||||
#define TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
|
||||
TypeList<T1, TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>
|
||||
#define TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \
|
||||
TypeList<T1, TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>
|
||||
#define TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \
|
||||
TypeList<T1, TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>
|
||||
#define POCO_TYPELIST_1(T0) TypeList<T0, NullTypeList>
|
||||
#define POCO_TYPELIST_2(T0, T1) TypeList<T0, POCO_TYPELIST_1(T1)>
|
||||
#define POCO_TYPELIST_3(T0, T1, T2) TypeList<T0, POCO_TYPELIST_2(T1, T2)>
|
||||
#define POCO_TYPELIST_4(T0, T1, T2, T3) TypeList<T0, POCO_TYPELIST_3(T1, T2, T3)>
|
||||
#define POCO_TYPELIST_5(T0, T1, T2, T3, T4) TypeList<T0, POCO_TYPELIST_4(T1, T2, T3, T4)>
|
||||
#define POCO_TYPELIST_6(T0, T1, T2, T3, T4, T5) TypeList<T0, POCO_TYPELIST_5(T1, T2, T3, T4, T5)>
|
||||
#define POCO_TYPELIST_7(T0, T1, T2, T3, T4, T5, T6) TypeList<T0, POCO_TYPELIST_6(T1, T2, T3, T4, T5, T6)>
|
||||
#define POCO_TYPELIST_8(T0, T1, T2, T3, T4, T5, T6, T7) TypeList<T0, POCO_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7)>
|
||||
#define POCO_TYPELIST_9(T0, T1, T2, T3, T4, T5, T6, T7, T8) TypeList<T0, POCO_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8)>
|
||||
#define POCO_TYPELIST_10(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) \
|
||||
TypeList<T0, POCO_TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9)>
|
||||
#define POCO_TYPELIST_11(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
|
||||
TypeList<T0, POCO_TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>
|
||||
#define POCO_TYPELIST_12(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
|
||||
TypeList<T0, POCO_TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>
|
||||
#define POCO_TYPELIST_13(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
|
||||
TypeList<T0, POCO_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>
|
||||
#define POCO_TYPELIST_14(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
|
||||
TypeList<T0, POCO_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>
|
||||
#define POCO_TYPELIST_15(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \
|
||||
TypeList<T0, POCO_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>
|
||||
#define POCO_TYPELIST_16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \
|
||||
TypeList<T0, POCO_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>
|
||||
#define POCO_TYPELIST_17(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \
|
||||
TypeList<T0, POCO_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)>
|
||||
#define POCO_TYPELIST_18(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) \
|
||||
TypeList<T0, POCO_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17)>
|
||||
#define POCO_TYPELIST_19(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) \
|
||||
TypeList<T0, POCO_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18)>
|
||||
#define POCO_TYPELIST_20(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) \
|
||||
TypeList<T0, POCO_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19)>
|
||||
|
||||
|
||||
template <typename T0 = NullTypeList,
|
||||
typename T1 = NullTypeList,
|
||||
typename T2 = NullTypeList,
|
||||
typename T3 = NullTypeList,
|
||||
typename T4 = NullTypeList,
|
||||
typename T5 = NullTypeList,
|
||||
typename T6 = NullTypeList,
|
||||
typename T7 = NullTypeList,
|
||||
typename T8 = NullTypeList,
|
||||
typename T9 = NullTypeList,
|
||||
typename T10 = NullTypeList,
|
||||
typename T11 = NullTypeList,
|
||||
typename T12 = NullTypeList,
|
||||
typename T13 = NullTypeList,
|
||||
typename T14 = NullTypeList,
|
||||
typename T15 = NullTypeList,
|
||||
typename T16 = NullTypeList,
|
||||
typename T17 = NullTypeList,
|
||||
typename T18 = NullTypeList,
|
||||
typename T19 = NullTypeList>
|
||||
struct TypeListType
|
||||
/// TypeListType takes 1 - 20 typename arguments.
|
||||
/// Usage:
|
||||
///
|
||||
/// TypeListType<T0, T1, ... , Tn>::HeadType typeList;
|
||||
///
|
||||
/// typeList is a TypeList of T0, T1, ... , Tn
|
||||
{
|
||||
private:
|
||||
typedef typename TypeListType<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::HeadType TailType;
|
||||
|
||||
public:
|
||||
typedef TypeList<T0, TailType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct TypeListType<>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<int n>
|
||||
@ -216,13 +272,18 @@ struct TypeGetter<0, TypeList<Head, Tail> >
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TypeLocator
|
||||
///
|
||||
|
||||
template <class Head, class T>
|
||||
struct TypeLocator;
|
||||
|
||||
/// TypeLocator returns the first occurrence of the type T in Head
|
||||
/// or -1 if the type is not found.
|
||||
///
|
||||
/// Usage example:
|
||||
///
|
||||
/// TypeLocator<Head, int>::HeadType TypeLoc;
|
||||
///
|
||||
/// if (2 == TypeLoc.value) ...
|
||||
///
|
||||
|
||||
|
||||
template <class T>
|
||||
struct TypeLocator<NullTypeList, T>
|
||||
@ -248,13 +309,20 @@ public:
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TypeAppender
|
||||
///
|
||||
|
||||
template <class Head, class T>
|
||||
struct TypeAppender;
|
||||
|
||||
/// TypeAppender appends T (type or a TypeList) to Head.
|
||||
///
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char>::HeadType Type1;
|
||||
/// typedef TypeAppender<Type1, int>::HeadType Type2;
|
||||
/// (Type2 is a TypeList of char,int)
|
||||
///
|
||||
/// typedef TypeListType<float, double>::HeadType Type3;
|
||||
/// typedef TypeAppender<Type2, Type3>::HeadType Type4;
|
||||
/// (Type4 is a TypeList of char,int,float,double)
|
||||
///
|
||||
|
||||
template<>
|
||||
struct TypeAppender<NullTypeList, NullTypeList>
|
||||
@ -266,7 +334,7 @@ struct TypeAppender<NullTypeList, NullTypeList>
|
||||
template<class T>
|
||||
struct TypeAppender<NullTypeList, T>
|
||||
{
|
||||
typedef TYPELIST_1(T) HeadType;
|
||||
typedef POCO_TYPELIST_1(T) HeadType;
|
||||
};
|
||||
|
||||
|
||||
@ -284,32 +352,161 @@ struct TypeAppender<TypeList<Head, Tail>, T>
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// TypeEraser
|
||||
///
|
||||
|
||||
template <class HEad, class T>
|
||||
struct TypeEraser;
|
||||
template <class Head, class T>
|
||||
struct TypeOneEraser;
|
||||
/// TypeOneEraser erases the first occurence of the type T in Head.
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char, int, float>::HeadType Type3;
|
||||
/// typedef TypeOneEraser<Type3, int>::HeadType Type2;
|
||||
/// (Type2 is a TypeList of char,float)
|
||||
///
|
||||
|
||||
|
||||
template <class T>
|
||||
struct TypeEraser<NullTypeList, T>
|
||||
struct TypeOneEraser<NullTypeList, T>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail>
|
||||
struct TypeEraser<TypeList<T, Tail>, T>
|
||||
struct TypeOneEraser<TypeList<T, Tail>, T>
|
||||
{
|
||||
typedef Tail HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct TypeEraser<TypeList<Head, Tail>, T>
|
||||
struct TypeOneEraser<TypeList<Head, Tail>, T>
|
||||
{
|
||||
typedef TypeList <Head, typename TypeEraser<Tail, T>::HeadType> HeadType;
|
||||
typedef TypeList <Head, typename TypeOneEraser<Tail, T>::HeadType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class T>
|
||||
struct TypeAllEraser;
|
||||
/// TypeAllEraser erases all the occurences of the type T in Head.
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char, int, float, int>::HeadType Type4;
|
||||
/// typedef TypeAllEraser<Type4, int>::HeadType Type2;
|
||||
/// (Type2 is a TypeList of char,float)
|
||||
///
|
||||
|
||||
|
||||
template <class T>
|
||||
struct TypeAllEraser<NullTypeList, T>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail>
|
||||
struct TypeAllEraser<TypeList<T, Tail>, T>
|
||||
{
|
||||
typedef typename TypeAllEraser<Tail, T>::HeadType HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct TypeAllEraser<TypeList<Head, Tail>, T>
|
||||
{
|
||||
typedef TypeList <Head, typename TypeAllEraser<Tail, T>::HeadType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head>
|
||||
struct TypeDuplicateEraser;
|
||||
/// TypeDuplicateEraser erases all but the first occurence of the type T in Head.
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char, int, float, int>::HeadType Type4;
|
||||
/// typedef TypeDuplicateEraser<Type4, int>::HeadType Type3;
|
||||
/// (Type3 is a TypeList of char,int,float)
|
||||
///
|
||||
|
||||
|
||||
template <>
|
||||
struct TypeDuplicateEraser<NullTypeList>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct TypeDuplicateEraser<TypeList<Head, Tail> >
|
||||
{
|
||||
private:
|
||||
typedef typename TypeDuplicateEraser<Tail>::HeadType L1;
|
||||
typedef typename TypeOneEraser<L1, Head>::HeadType L2;
|
||||
public:
|
||||
typedef TypeList<Head, L2> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class T, class R>
|
||||
struct TypeOneReplacer;
|
||||
/// TypeOneReplacer replaces the first occurence
|
||||
/// of the type T in Head with type R.
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char, int, float, int>::HeadType Type4;
|
||||
/// typedef TypeOneReplacer<Type4, int, double>::HeadType TypeR;
|
||||
/// (TypeR is a TypeList of char,double,float,int)
|
||||
///
|
||||
|
||||
template <class T, class R>
|
||||
struct TypeOneReplacer<NullTypeList, T, R>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail, class R>
|
||||
struct TypeOneReplacer<TypeList<T, Tail>, T, R>
|
||||
{
|
||||
typedef TypeList<R, Tail> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T, class R>
|
||||
struct TypeOneReplacer<TypeList<Head, Tail>, T, R>
|
||||
{
|
||||
typedef TypeList<Head, typename TypeOneReplacer<Tail, T, R>::HeadType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class T, class R>
|
||||
struct TypeAllReplacer;
|
||||
/// TypeAllReplacer replaces all the occurences
|
||||
/// of the type T in Head with type R.
|
||||
/// Usage:
|
||||
///
|
||||
/// typedef TypeListType<char, int, float, int>::HeadType Type4;
|
||||
/// typedef TypeAllReplacer<Type4, int, double>::HeadType TypeR;
|
||||
/// (TypeR is a TypeList of char,double,float,double)
|
||||
///
|
||||
|
||||
|
||||
template <class T, class R>
|
||||
struct TypeAllReplacer<NullTypeList, T, R>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class T, class Tail, class R>
|
||||
struct TypeAllReplacer<TypeList<T, Tail>, T, R>
|
||||
{
|
||||
typedef TypeList<R, typename TypeAllReplacer<Tail, T, R>::HeadType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template <class Head, class Tail, class T, class R>
|
||||
struct TypeAllReplacer<TypeList<Head, Tail>, T, R>
|
||||
{
|
||||
typedef TypeList<Head, typename TypeAllReplacer<Tail, T, R>::HeadType> HeadType;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="TestSuite"
|
||||
ProjectGUID="{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
||||
Keyword="Win32Proj"
|
||||
@ -450,6 +450,10 @@
|
||||
RelativePath=".\src\TuplesTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\TypeListTest.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -526,6 +530,10 @@
|
||||
RelativePath=".\src\TuplesTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\TypeListTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "AnyTest.h"
|
||||
#include "FormatTest.h"
|
||||
#include "TuplesTest.h"
|
||||
#include "TypeListTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* CoreTestSuite::suite()
|
||||
@ -71,6 +72,7 @@ CppUnit::Test* CoreTestSuite::suite()
|
||||
pSuite->addTest(AnyTest::suite());
|
||||
pSuite->addTest(FormatTest::suite());
|
||||
pSuite->addTest(TuplesTest::suite());
|
||||
pSuite->addTest(TypeListTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TuplesTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.cpp#2 $
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -39,12 +39,29 @@
|
||||
|
||||
using Poco::TypeList;
|
||||
using Poco::NullTypeList;
|
||||
using Poco::TypeListType;
|
||||
using Poco::TypeGetter;
|
||||
using Poco::TypeLocator;
|
||||
using Poco::TypeAppender;
|
||||
using Poco::TypeEraser;
|
||||
using Poco::TypeOneEraser;
|
||||
using Poco::TypeAllEraser;
|
||||
using Poco::TypeDuplicateEraser;
|
||||
using Poco::TypeOneReplacer;
|
||||
using Poco::TypeAllReplacer;
|
||||
using Poco::Tuple;
|
||||
using Poco::Void;
|
||||
using Poco::Int8;
|
||||
using Poco::UInt8;
|
||||
using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
using Poco::Int8;
|
||||
using Poco::UInt8;
|
||||
using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
|
||||
|
||||
TuplesTest::TuplesTest(const std::string& name): CppUnit::TestCase(name)
|
||||
@ -57,7 +74,7 @@ TuplesTest::~TuplesTest()
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testSimpleTuple()
|
||||
void TuplesTest::testTuple1()
|
||||
{
|
||||
Tuple<int> t;
|
||||
assert (t.length == 1);
|
||||
@ -87,7 +104,109 @@ void TuplesTest::testSimpleTuple()
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTupleSize5()
|
||||
void TuplesTest::testTuple2()
|
||||
{
|
||||
Tuple<int, Void> dummy1;
|
||||
assert (dummy1.length == 2);
|
||||
dummy1.set<0>(-1);
|
||||
assert (dummy1.get<0>() == -1);
|
||||
//test partial init
|
||||
Tuple<int, Void> dummy11(0);
|
||||
|
||||
Tuple<Void, int> dummy2;
|
||||
dummy2.set<1>(-1);
|
||||
assert (dummy2.get<1>() == -1);
|
||||
|
||||
Tuple<Void, int> dummy3;
|
||||
dummy3.set<1>(-1);
|
||||
assert (dummy3.get<1>() == -1);
|
||||
|
||||
Tuple<std::string, int> aTuple;
|
||||
aTuple.set<0>("str");
|
||||
aTuple.set<1>(1);
|
||||
assert (aTuple.get<0>() == "str");
|
||||
assert (aTuple.get<1>() == 1);
|
||||
|
||||
Tuple<std::string, int> aTuple2(aTuple);
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.set<1>(99);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple2.set<1>(100000);
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple3()
|
||||
{
|
||||
Tuple<int, Void, Void> dummy1;
|
||||
assert (dummy1.length == 3);
|
||||
dummy1.set<0>(-1);
|
||||
assert (dummy1.get<0>() == -1);
|
||||
//test partial init
|
||||
Tuple<int, Void, Void> dummy11(0);
|
||||
|
||||
Tuple<Void, int, Void> dummy2;
|
||||
dummy2.set<1>(-1);
|
||||
assert (dummy2.get<1>() == -1);
|
||||
|
||||
Tuple<Void, Void, int> dummy3;
|
||||
dummy3.set<2>(-1);
|
||||
assert (dummy3.get<2>() == -1);
|
||||
|
||||
Tuple<std::string, int, bool> aTuple;
|
||||
aTuple.set<0>("str");
|
||||
aTuple.set<1>(1);
|
||||
aTuple.set<2>(true);
|
||||
assert (aTuple.get<0>() == "str");
|
||||
assert (aTuple.get<1>() == 1);
|
||||
assert (aTuple.get<2>());
|
||||
|
||||
Tuple<std::string, int, bool> aTuple2(aTuple);
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.set<2>(false);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple2.set<1>(100000);
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple4()
|
||||
{
|
||||
Tuple<int, Void, Void, Void> dummy1;
|
||||
assert (dummy1.length == 4);
|
||||
dummy1.set<0>(-1);
|
||||
assert (dummy1.get<0>() == -1);
|
||||
//test partial init
|
||||
Tuple<int, Void, Void, Void> dummy11(0);
|
||||
|
||||
Tuple<Void, int, Void, Void> dummy2;
|
||||
dummy2.set<1>(-1);
|
||||
assert (dummy2.get<1>() == -1);
|
||||
|
||||
Tuple<Void, Void, Void, int> dummy3;
|
||||
dummy3.set<3>(-1);
|
||||
assert (dummy3.get<3>() == -1);
|
||||
|
||||
Tuple<std::string, int, bool, float> aTuple;
|
||||
aTuple.set<0>("str");
|
||||
aTuple.set<1>(1);
|
||||
aTuple.set<2>(true);
|
||||
aTuple.set<3>(3.14f);
|
||||
assert (aTuple.get<0>() == "str");
|
||||
assert (aTuple.get<1>() == 1);
|
||||
assert (aTuple.get<2>());
|
||||
assert (aTuple.get<3>() >= 3.13f && aTuple.get<3>() <= 3.15f);
|
||||
|
||||
Tuple<std::string, int, bool, float> aTuple2(aTuple);
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.set<2>(false);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple2.set<1>(100000);
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple5()
|
||||
{
|
||||
Tuple<int, Void, Void, Void, Void> dummy1;
|
||||
assert (dummy1.length == 5);
|
||||
@ -125,11 +244,229 @@ void TuplesTest::testTupleSize5()
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTupleSize10()
|
||||
void TuplesTest::testTuple6()
|
||||
{
|
||||
Tuple<std::string, int, bool, float, char, long, double, short, std::string, int> aTuple;
|
||||
Tuple<std::string, int, bool, float, char, long> aTuple;
|
||||
assert (aTuple.length == 6);
|
||||
Tuple<std::string, int, bool, float, char, long>
|
||||
aTuple2("1", 1, true, 3.14f, 'c', 999);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple7()
|
||||
{
|
||||
Tuple<std::string, int, bool, float, char, long, double> aTuple;
|
||||
assert (aTuple.length == 7);
|
||||
Tuple<std::string, int, bool, float, char, long, double>
|
||||
aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple8()
|
||||
{
|
||||
Tuple<std::string, int, bool, float, char, long, double, short> aTuple;
|
||||
assert (aTuple.length == 8);
|
||||
Tuple<std::string, int, bool, float, char, long, double, short>
|
||||
aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
void TuplesTest::testTuple9()
|
||||
{
|
||||
Tuple<std::string, int, bool, float, char, long, double, short, std::string> aTuple;
|
||||
assert (aTuple.length == 9);
|
||||
Tuple<std::string, int, bool, float, char, long, double, short, std::string>
|
||||
aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2");
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple10()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 10);
|
||||
Tuple<std::string, int, bool, float, char, long, double, short, std::string, int> aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple11()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 11);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1");
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple12()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 12);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple13()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 13);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple14()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 14);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple15()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 15);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c');
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple16()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char, long> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 16);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple17()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char, long, double> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 17);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple18()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char, long, double, short> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 18);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14, 32700);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple19()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char, long, double, short, std::string> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 19);
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2");
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
aTuple2.get<1>()++;
|
||||
assert (aTuple < aTuple2);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTuple20()
|
||||
{
|
||||
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
|
||||
std::string, int, bool, float, char, long, double, short, std::string, int> TupleType;
|
||||
|
||||
TupleType aTuple;
|
||||
assert (aTuple.length == 20);
|
||||
|
||||
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2);
|
||||
assert (aTuple != aTuple2);
|
||||
aTuple = aTuple2;
|
||||
assert (aTuple == aTuple2);
|
||||
@ -145,114 +482,7 @@ void TuplesTest::testMemOverhead()
|
||||
assert (sz == 4 || sz == 8); //depending on architecture and alignment
|
||||
Tuple<long> notSoSmall(0);
|
||||
sz = sizeof(notSoSmall);
|
||||
assert (sz == 8);
|
||||
}
|
||||
|
||||
|
||||
void TuplesTest::testTypeList()
|
||||
{
|
||||
typedef TYPELIST_15(Poco::Int8,
|
||||
Poco::UInt8,
|
||||
Poco::Int16,
|
||||
Poco::UInt16,
|
||||
Poco::Int32,
|
||||
Poco::UInt32,
|
||||
float,
|
||||
double,
|
||||
Poco::Int8,
|
||||
Poco::UInt8,
|
||||
Poco::Int16,
|
||||
Poco::UInt16,
|
||||
Poco::Int32,
|
||||
Poco::UInt32,
|
||||
float) Type15;
|
||||
|
||||
TypeLocator<Type15, Poco::Int8> pos0; pos0;
|
||||
TypeLocator<Type15, Poco::UInt8> pos1; pos1;
|
||||
TypeLocator<Type15, Poco::Int16> pos2; pos2;
|
||||
TypeLocator<Type15, Poco::UInt16> pos3; pos3;
|
||||
TypeLocator<Type15, Poco::Int32> pos4; pos4;
|
||||
TypeLocator<Type15, Poco::UInt32> pos5; pos5;
|
||||
TypeLocator<Type15, float> pos6; pos6;
|
||||
TypeLocator<Type15, double> pos7; pos7;
|
||||
TypeLocator<Type15, Poco::Int8> pos8; pos8;
|
||||
TypeLocator<Type15, std::string> posUnknown; posUnknown;
|
||||
|
||||
assert (pos0.value == 0);
|
||||
assert (pos1.value == 1);
|
||||
assert (pos2.value == 2);
|
||||
assert (pos3.value == 3);
|
||||
assert (pos4.value == 4);
|
||||
assert (pos5.value == 5);
|
||||
assert (pos6.value == 6);
|
||||
assert (pos7.value == 7);
|
||||
assert (pos8.value == 0);
|
||||
assert (posUnknown.value == -1);
|
||||
|
||||
assert (typeid(TypeGetter<0, Type15>::HeadType) == typeid(Poco::Int8));
|
||||
assert (typeid(TypeGetter<0, Type15>::ConstHeadType) == typeid(const Poco::Int8));
|
||||
assert (typeid(TypeGetter<1, Type15>::HeadType) == typeid(Poco::UInt8));
|
||||
assert (typeid(TypeGetter<1, Type15>::ConstHeadType) == typeid(const Poco::UInt8));
|
||||
assert (typeid(TypeGetter<2, Type15>::HeadType) == typeid(Poco::Int16));
|
||||
assert (typeid(TypeGetter<2, Type15>::ConstHeadType) == typeid(const Poco::Int16));
|
||||
assert (typeid(TypeGetter<3, Type15>::HeadType) == typeid(Poco::UInt16));
|
||||
assert (typeid(TypeGetter<3, Type15>::ConstHeadType) == typeid(const Poco::UInt16));
|
||||
assert (typeid(TypeGetter<4, Type15>::HeadType) == typeid(Poco::Int32));
|
||||
assert (typeid(TypeGetter<4, Type15>::ConstHeadType) == typeid(const Poco::Int32));
|
||||
assert (typeid(TypeGetter<5, Type15>::HeadType) == typeid(Poco::UInt32));
|
||||
assert (typeid(TypeGetter<5, Type15>::ConstHeadType) == typeid(const Poco::UInt32));
|
||||
assert (typeid(TypeGetter<6, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<6, Type15>::ConstHeadType) == typeid(const float));
|
||||
assert (typeid(TypeGetter<7, Type15>::HeadType) == typeid(double));
|
||||
assert (typeid(TypeGetter<7, Type15>::ConstHeadType) == typeid(const double));
|
||||
assert (typeid(TypeGetter<8, Type15>::HeadType) == typeid(Poco::Int8));
|
||||
assert (typeid(TypeGetter<8, Type15>::ConstHeadType) == typeid(const Poco::Int8));
|
||||
assert (typeid(TypeGetter<9, Type15>::HeadType) == typeid(Poco::UInt8));
|
||||
assert (typeid(TypeGetter<9, Type15>::ConstHeadType) == typeid(const Poco::UInt8));
|
||||
assert (typeid(TypeGetter<10, Type15>::HeadType) == typeid(Poco::Int16));
|
||||
assert (typeid(TypeGetter<10, Type15>::ConstHeadType) == typeid(const Poco::Int16));
|
||||
assert (typeid(TypeGetter<11, Type15>::HeadType) == typeid(Poco::UInt16));
|
||||
assert (typeid(TypeGetter<11, Type15>::ConstHeadType) == typeid(const Poco::UInt16));
|
||||
assert (typeid(TypeGetter<12, Type15>::HeadType) == typeid(Poco::Int32));
|
||||
assert (typeid(TypeGetter<12, Type15>::ConstHeadType) == typeid(const Poco::Int32));
|
||||
assert (typeid(TypeGetter<13, Type15>::HeadType) == typeid(Poco::UInt32));
|
||||
assert (typeid(TypeGetter<13, Type15>::ConstHeadType) == typeid(const Poco::UInt32));
|
||||
assert (typeid(TypeGetter<14, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<14, Type15>::ConstHeadType) == typeid(const float));
|
||||
|
||||
typedef TYPELIST_1(Poco::Int8) Type1;
|
||||
assert (1 == Type1::length);
|
||||
typedef TYPELIST_2(Poco::Int16, Poco::Int32) Type2;
|
||||
assert (2 == Type2::length);
|
||||
typedef TypeAppender<Type1, Type2>::HeadType Type3;
|
||||
assert (3 == Type3::length);
|
||||
|
||||
assert (typeid(TypeGetter<0, Type3>::HeadType) == typeid(Poco::Int8));
|
||||
assert (typeid(TypeGetter<1, Type3>::HeadType) == typeid(Poco::Int16));
|
||||
assert (typeid(TypeGetter<2, Type3>::HeadType) == typeid(Poco::Int32));
|
||||
|
||||
TypeLocator<Type3, Poco::Int8> posNo1; posNo1;
|
||||
TypeLocator<Type3, Poco::Int16> posNo2; posNo2;
|
||||
TypeLocator<Type3, Poco::Int32> posNo3; posNo3;
|
||||
|
||||
assert (posNo1.value == 0);
|
||||
assert (posNo2.value == 1);
|
||||
assert (posNo3.value == 2);
|
||||
|
||||
typedef TypeEraser<Type3, Poco::Int8>::HeadType TypeEraser1;
|
||||
assert (2 == TypeEraser1::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser1>::HeadType) == typeid(Poco::Int16));
|
||||
assert (typeid(TypeGetter<1, TypeEraser1>::HeadType) == typeid(Poco::Int32));
|
||||
|
||||
typedef TypeEraser<Type3, Poco::Int16>::HeadType TypeEraser2;
|
||||
assert (2 == TypeEraser2::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser2>::HeadType) == typeid(Poco::Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser2>::HeadType) == typeid(Poco::Int32));
|
||||
|
||||
typedef TypeEraser<Type3, Poco::Int32>::HeadType TypeEraser3;
|
||||
assert (2 == TypeEraser3::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser3>::HeadType) == typeid(Poco::Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser3>::HeadType) == typeid(Poco::Int16));
|
||||
assert (sz == 8 || sz == 16); //depending on architecture and alignment
|
||||
}
|
||||
|
||||
|
||||
@ -270,12 +500,27 @@ CppUnit::Test* TuplesTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TuplesTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TuplesTest, testSimpleTuple);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTupleSize5);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTupleSize10);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple1);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple2);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple3);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple4);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple5);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple6);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple7);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple8);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple9);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple10);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple11);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple12);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple13);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple14);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple15);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple16);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple17);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple18);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple19);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTuple20);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testMemOverhead);
|
||||
CppUnit_addTest(pSuite, TuplesTest, testTypeList);
|
||||
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TuplesTest.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.h#2 $
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.h#1 $
|
||||
//
|
||||
// Definition of the TuplesTest class.
|
||||
//
|
||||
@ -46,12 +46,27 @@ public:
|
||||
TuplesTest(const std::string& name);
|
||||
~TuplesTest();
|
||||
|
||||
void testSimpleTuple();
|
||||
void testTupleSize5();
|
||||
void testTupleSize10();
|
||||
void testTuple1();
|
||||
void testTuple2();
|
||||
void testTuple3();
|
||||
void testTuple4();
|
||||
void testTuple5();
|
||||
void testTuple6();
|
||||
void testTuple7();
|
||||
void testTuple8();
|
||||
void testTuple9();
|
||||
void testTuple10();
|
||||
void testTuple11();
|
||||
void testTuple12();
|
||||
void testTuple13();
|
||||
void testTuple14();
|
||||
void testTuple15();
|
||||
void testTuple16();
|
||||
void testTuple17();
|
||||
void testTuple18();
|
||||
void testTuple19();
|
||||
void testTuple20();
|
||||
void testMemOverhead();
|
||||
void testTypeList();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
|
474
Foundation/testsuite/src/TypeListTest.cpp
Normal file
474
Foundation/testsuite/src/TypeListTest.cpp
Normal file
@ -0,0 +1,474 @@
|
||||
//
|
||||
// TypeListTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.cpp#1 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "TypeListTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Tuple.h"
|
||||
#include "Poco/TypeList.h"
|
||||
#include "Poco/Void.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using Poco::TypeList;
|
||||
using Poco::Tuple;
|
||||
using Poco::NullTypeList;
|
||||
using Poco::TypeListType;
|
||||
using Poco::TypeGetter;
|
||||
using Poco::TypeLocator;
|
||||
using Poco::TypeAppender;
|
||||
using Poco::TypeOneEraser;
|
||||
using Poco::TypeAllEraser;
|
||||
using Poco::TypeDuplicateEraser;
|
||||
using Poco::TypeOneReplacer;
|
||||
using Poco::TypeAllReplacer;
|
||||
using Poco::Int8;
|
||||
using Poco::UInt8;
|
||||
using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
using Poco::Int8;
|
||||
using Poco::UInt8;
|
||||
using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
using Poco::Void;
|
||||
|
||||
|
||||
TypeListTest::TypeListTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TypeListTest::~TypeListTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TypeListTest::testTypeListMacro()
|
||||
{
|
||||
typedef POCO_TYPELIST_15(Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
float,
|
||||
double,
|
||||
Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
float) Type15;
|
||||
|
||||
Tuple<TypeGetter<0, Type15>::HeadType,
|
||||
TypeGetter<1, Type15>::HeadType,
|
||||
TypeGetter<2, Type15>::HeadType,
|
||||
TypeGetter<3, Type15>::HeadType,
|
||||
TypeGetter<4, Type15>::HeadType,
|
||||
TypeGetter<5, Type15>::HeadType,
|
||||
TypeGetter<6, Type15>::HeadType,
|
||||
TypeGetter<7, Type15>::HeadType,
|
||||
TypeGetter<8, Type15>::HeadType,
|
||||
TypeGetter<9, Type15>::HeadType> tuple;
|
||||
|
||||
static TypeLocator<Type15, Int8> pos0;
|
||||
static TypeLocator<Type15, UInt8> pos1;
|
||||
static TypeLocator<Type15, Int16> pos2;
|
||||
static TypeLocator<Type15, UInt16> pos3;
|
||||
static TypeLocator<Type15, Int32> pos4;
|
||||
static TypeLocator<Type15, UInt32> pos5;
|
||||
static TypeLocator<Type15, float> pos6;
|
||||
static TypeLocator<Type15, double> pos7;
|
||||
static TypeLocator<Type15, Int8> pos8;
|
||||
static TypeLocator<Type15, std::string> posUnknown;
|
||||
|
||||
assert (pos0.value == 0);
|
||||
assert (pos1.value == 1);
|
||||
assert (pos2.value == 2);
|
||||
assert (pos3.value == 3);
|
||||
assert (pos4.value == 4);
|
||||
assert (pos5.value == 5);
|
||||
assert (pos6.value == 6);
|
||||
assert (pos7.value == 7);
|
||||
assert (pos8.value == 0);
|
||||
assert (posUnknown.value == -1);
|
||||
|
||||
tuple.set<TypeLocator<Type15, Int32>::value >(-123);
|
||||
assert (-123 == tuple.get<4>());
|
||||
|
||||
assert (typeid(TypeGetter<0, Type15>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<0, Type15>::ConstHeadType) == typeid(const Int8));
|
||||
assert (typeid(TypeGetter<1, Type15>::HeadType) == typeid(UInt8));
|
||||
assert (typeid(TypeGetter<1, Type15>::ConstHeadType) == typeid(const UInt8));
|
||||
assert (typeid(TypeGetter<2, Type15>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, Type15>::ConstHeadType) == typeid(const Int16));
|
||||
assert (typeid(TypeGetter<3, Type15>::HeadType) == typeid(UInt16));
|
||||
assert (typeid(TypeGetter<3, Type15>::ConstHeadType) == typeid(const UInt16));
|
||||
assert (typeid(TypeGetter<4, Type15>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<4, Type15>::ConstHeadType) == typeid(const Int32));
|
||||
assert (typeid(TypeGetter<5, Type15>::HeadType) == typeid(UInt32));
|
||||
assert (typeid(TypeGetter<5, Type15>::ConstHeadType) == typeid(const UInt32));
|
||||
assert (typeid(TypeGetter<6, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<6, Type15>::ConstHeadType) == typeid(const float));
|
||||
assert (typeid(TypeGetter<7, Type15>::HeadType) == typeid(double));
|
||||
assert (typeid(TypeGetter<7, Type15>::ConstHeadType) == typeid(const double));
|
||||
assert (typeid(TypeGetter<8, Type15>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<8, Type15>::ConstHeadType) == typeid(const Int8));
|
||||
assert (typeid(TypeGetter<9, Type15>::HeadType) == typeid(UInt8));
|
||||
assert (typeid(TypeGetter<9, Type15>::ConstHeadType) == typeid(const UInt8));
|
||||
assert (typeid(TypeGetter<10, Type15>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<10, Type15>::ConstHeadType) == typeid(const Int16));
|
||||
assert (typeid(TypeGetter<11, Type15>::HeadType) == typeid(UInt16));
|
||||
assert (typeid(TypeGetter<11, Type15>::ConstHeadType) == typeid(const UInt16));
|
||||
assert (typeid(TypeGetter<12, Type15>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<12, Type15>::ConstHeadType) == typeid(const Int32));
|
||||
assert (typeid(TypeGetter<13, Type15>::HeadType) == typeid(UInt32));
|
||||
assert (typeid(TypeGetter<13, Type15>::ConstHeadType) == typeid(const UInt32));
|
||||
assert (typeid(TypeGetter<14, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<14, Type15>::ConstHeadType) == typeid(const float));
|
||||
|
||||
typedef POCO_TYPELIST_1(Int8) Type1;
|
||||
assert (1 == Type1::length);
|
||||
typedef POCO_TYPELIST_2(Int16, Int32) Type2;
|
||||
assert (2 == Type2::length);
|
||||
typedef TypeAppender<Type1, Type2>::HeadType Type3;
|
||||
assert (3 == Type3::length);
|
||||
|
||||
assert (typeid(TypeGetter<0, Type3>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, Type3>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, Type3>::HeadType) == typeid(Int32));
|
||||
|
||||
static TypeLocator<Type3, Int8> posNo1;
|
||||
static TypeLocator<Type3, Int16> posNo2;
|
||||
static TypeLocator<Type3, Int32> posNo3;
|
||||
|
||||
assert (posNo1.value == 0);
|
||||
assert (posNo2.value == 1);
|
||||
assert (posNo3.value == 2);
|
||||
|
||||
typedef TypeOneEraser<Type3, Int8>::HeadType TypeEraser1;
|
||||
assert (2 == TypeEraser1::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<1, TypeEraser1>::HeadType) == typeid(Int32));
|
||||
|
||||
typedef TypeOneEraser<Type3, Int16>::HeadType TypeEraser2;
|
||||
assert (2 == TypeEraser2::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser2>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser2>::HeadType) == typeid(Int32));
|
||||
|
||||
typedef TypeOneEraser<Type3, Int32>::HeadType TypeEraser3;
|
||||
assert (2 == TypeEraser3::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser3>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser3>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef POCO_TYPELIST_5(Int8,
|
||||
Int16,
|
||||
Int8,
|
||||
Int16,
|
||||
Int8) Type5;
|
||||
typedef TypeAllEraser<Type5, Int8>::HeadType TypeAllEraser3;
|
||||
assert (2 == TypeAllEraser3::length);
|
||||
assert (typeid(TypeGetter<0, TypeAllEraser3>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<1, TypeAllEraser3>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeDuplicateEraser<Type5>::HeadType TypeDuplicateEraser1;
|
||||
assert (2 == TypeDuplicateEraser1::length);
|
||||
assert (typeid(TypeGetter<0, TypeDuplicateEraser1>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeDuplicateEraser1>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeOneReplacer<Type5, Int8, Int32>::HeadType TypeOneReplacer1;
|
||||
assert (5 == TypeOneReplacer1::length);
|
||||
assert (typeid(TypeGetter<0, TypeOneReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<1, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<3, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<4, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
||||
|
||||
typedef TypeAllReplacer<Type5, Int8, Int32>::HeadType TypeAllReplacer1;
|
||||
assert (5 == TypeAllReplacer1::length);
|
||||
assert (typeid(TypeGetter<0, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<1, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<3, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<4, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
}
|
||||
|
||||
|
||||
void TypeListTest::testTypeListTemplate()
|
||||
{
|
||||
typedef TypeListType<Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
float,
|
||||
double,
|
||||
Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
float>::HeadType Type15;
|
||||
|
||||
Tuple<TypeGetter<0, Type15>::HeadType,
|
||||
TypeGetter<1, Type15>::HeadType,
|
||||
TypeGetter<2, Type15>::HeadType,
|
||||
TypeGetter<3, Type15>::HeadType,
|
||||
TypeGetter<4, Type15>::HeadType,
|
||||
TypeGetter<5, Type15>::HeadType,
|
||||
TypeGetter<6, Type15>::HeadType,
|
||||
TypeGetter<7, Type15>::HeadType,
|
||||
TypeGetter<8, Type15>::HeadType,
|
||||
TypeGetter<9, Type15>::HeadType> tuple;
|
||||
|
||||
static TypeLocator<Type15, Int8> pos0;
|
||||
static TypeLocator<Type15, UInt8> pos1;
|
||||
static TypeLocator<Type15, Int16> pos2;
|
||||
static TypeLocator<Type15, UInt16> pos3;
|
||||
static TypeLocator<Type15, Int32> pos4;
|
||||
static TypeLocator<Type15, UInt32> pos5;
|
||||
static TypeLocator<Type15, float> pos6;
|
||||
static TypeLocator<Type15, double> pos7;
|
||||
static TypeLocator<Type15, Int8> pos8;
|
||||
static TypeLocator<Type15, std::string> posUnknown;
|
||||
|
||||
assert (pos0.value == 0);
|
||||
assert (pos1.value == 1);
|
||||
assert (pos2.value == 2);
|
||||
assert (pos3.value == 3);
|
||||
assert (pos4.value == 4);
|
||||
assert (pos5.value == 5);
|
||||
assert (pos6.value == 6);
|
||||
assert (pos7.value == 7);
|
||||
assert (pos8.value == 0);
|
||||
assert (posUnknown.value == -1);
|
||||
|
||||
tuple.set<TypeLocator<Type15, Int32>::value >(-123);
|
||||
assert (-123 == tuple.get<4>());
|
||||
|
||||
assert (typeid(TypeGetter<0, Type15>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<0, Type15>::ConstHeadType) == typeid(const Int8));
|
||||
assert (typeid(TypeGetter<1, Type15>::HeadType) == typeid(UInt8));
|
||||
assert (typeid(TypeGetter<1, Type15>::ConstHeadType) == typeid(const UInt8));
|
||||
assert (typeid(TypeGetter<2, Type15>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, Type15>::ConstHeadType) == typeid(const Int16));
|
||||
assert (typeid(TypeGetter<3, Type15>::HeadType) == typeid(UInt16));
|
||||
assert (typeid(TypeGetter<3, Type15>::ConstHeadType) == typeid(const UInt16));
|
||||
assert (typeid(TypeGetter<4, Type15>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<4, Type15>::ConstHeadType) == typeid(const Int32));
|
||||
assert (typeid(TypeGetter<5, Type15>::HeadType) == typeid(UInt32));
|
||||
assert (typeid(TypeGetter<5, Type15>::ConstHeadType) == typeid(const UInt32));
|
||||
assert (typeid(TypeGetter<6, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<6, Type15>::ConstHeadType) == typeid(const float));
|
||||
assert (typeid(TypeGetter<7, Type15>::HeadType) == typeid(double));
|
||||
assert (typeid(TypeGetter<7, Type15>::ConstHeadType) == typeid(const double));
|
||||
assert (typeid(TypeGetter<8, Type15>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<8, Type15>::ConstHeadType) == typeid(const Int8));
|
||||
assert (typeid(TypeGetter<9, Type15>::HeadType) == typeid(UInt8));
|
||||
assert (typeid(TypeGetter<9, Type15>::ConstHeadType) == typeid(const UInt8));
|
||||
assert (typeid(TypeGetter<10, Type15>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<10, Type15>::ConstHeadType) == typeid(const Int16));
|
||||
assert (typeid(TypeGetter<11, Type15>::HeadType) == typeid(UInt16));
|
||||
assert (typeid(TypeGetter<11, Type15>::ConstHeadType) == typeid(const UInt16));
|
||||
assert (typeid(TypeGetter<12, Type15>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<12, Type15>::ConstHeadType) == typeid(const Int32));
|
||||
assert (typeid(TypeGetter<13, Type15>::HeadType) == typeid(UInt32));
|
||||
assert (typeid(TypeGetter<13, Type15>::ConstHeadType) == typeid(const UInt32));
|
||||
assert (typeid(TypeGetter<14, Type15>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<14, Type15>::ConstHeadType) == typeid(const float));
|
||||
|
||||
typedef TypeListType<Int8>::HeadType Type1;
|
||||
assert (1 == Type1::length);
|
||||
typedef TypeListType<Int16, Int32>::HeadType Type2;
|
||||
assert (2 == Type2::length);
|
||||
typedef TypeAppender<Type1, Type2>::HeadType Type3;
|
||||
assert (3 == Type3::length);
|
||||
|
||||
assert (typeid(TypeGetter<0, Type3>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, Type3>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, Type3>::HeadType) == typeid(Int32));
|
||||
|
||||
static TypeLocator<Type3, Int8> posNo1;
|
||||
static TypeLocator<Type3, Int16> posNo2;
|
||||
static TypeLocator<Type3, Int32> posNo3;
|
||||
|
||||
assert (posNo1.value == 0);
|
||||
assert (posNo2.value == 1);
|
||||
assert (posNo3.value == 2);
|
||||
|
||||
typedef TypeOneEraser<Type3, Int8>::HeadType TypeEraser1;
|
||||
assert (2 == TypeEraser1::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<1, TypeEraser1>::HeadType) == typeid(Int32));
|
||||
|
||||
typedef TypeOneEraser<Type3, Int16>::HeadType TypeEraser2;
|
||||
assert (2 == TypeEraser2::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser2>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser2>::HeadType) == typeid(Int32));
|
||||
|
||||
typedef TypeOneEraser<Type3, Int32>::HeadType TypeEraser3;
|
||||
assert (2 == TypeEraser3::length);
|
||||
assert (typeid(TypeGetter<0, TypeEraser3>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeEraser3>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeListType<Int8,Int16,Int8,Int16,Int8>::HeadType Type5;
|
||||
typedef TypeAllEraser<Type5, Int8>::HeadType TypeAllEraser3;
|
||||
assert (2 == TypeAllEraser3::length);
|
||||
assert (typeid(TypeGetter<0, TypeAllEraser3>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<1, TypeAllEraser3>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeDuplicateEraser<Type5>::HeadType TypeDuplicateEraser1;
|
||||
assert (2 == TypeDuplicateEraser1::length);
|
||||
assert (typeid(TypeGetter<0, TypeDuplicateEraser1>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeDuplicateEraser1>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeOneReplacer<Type5, Int8, Int32>::HeadType TypeOneReplacer1;
|
||||
assert (5 == TypeOneReplacer1::length);
|
||||
assert (typeid(TypeGetter<0, TypeOneReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<1, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<3, TypeOneReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<4, TypeOneReplacer1>::HeadType) == typeid(Int8));
|
||||
|
||||
typedef TypeAllReplacer<Type5, Int8, Int32>::HeadType TypeAllReplacer1;
|
||||
assert (5 == TypeAllReplacer1::length);
|
||||
assert (typeid(TypeGetter<0, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<1, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<3, TypeAllReplacer1>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<4, TypeAllReplacer1>::HeadType) == typeid(Int32));
|
||||
|
||||
typedef TypeListType<Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void,Void>::HeadType TypeVoid;
|
||||
assert (typeid(TypeGetter<0, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<1, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<2, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<3, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<4, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<5, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<6, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<7, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<8, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<9, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<10, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<11, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<12, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<13, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<14, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<15, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<16, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<17, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<18, TypeVoid>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<19, TypeVoid>::HeadType) == typeid(Void));
|
||||
|
||||
|
||||
typedef TypeOneReplacer<TypeVoid, Void, Int8>::HeadType TypeFirstReplacer;
|
||||
assert (typeid(TypeGetter<0, TypeFirstReplacer>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<2, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<3, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<4, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<5, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<6, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<7, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<8, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<9, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<10, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<11, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<12, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<13, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<14, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<15, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<16, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<17, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<18, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
assert (typeid(TypeGetter<19, TypeFirstReplacer>::HeadType) == typeid(Void));
|
||||
|
||||
typedef TypeOneReplacer<TypeFirstReplacer, Void, Int16>::HeadType TypeSecondReplacer;
|
||||
assert (typeid(TypeGetter<0, TypeSecondReplacer>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeSecondReplacer>::HeadType) == typeid(Int16));
|
||||
|
||||
typedef TypeOneReplacer<TypeSecondReplacer, Void, Int32>::HeadType TypeThirdReplacer;
|
||||
assert (typeid(TypeGetter<0, TypeThirdReplacer>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeThirdReplacer>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeThirdReplacer>::HeadType) == typeid(Int32));
|
||||
|
||||
|
||||
typedef TypeAllReplacer<TypeThirdReplacer, Void, float>::HeadType TypeFourthReplacer;
|
||||
assert (typeid(TypeGetter<0, TypeFourthReplacer>::HeadType) == typeid(Int8));
|
||||
assert (typeid(TypeGetter<1, TypeFourthReplacer>::HeadType) == typeid(Int16));
|
||||
assert (typeid(TypeGetter<2, TypeFourthReplacer>::HeadType) == typeid(Int32));
|
||||
assert (typeid(TypeGetter<3, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<4, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<5, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<6, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<7, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<8, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<9, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<10, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<11, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<12, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<13, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<14, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<15, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<16, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<17, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<18, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
assert (typeid(TypeGetter<19, TypeFourthReplacer>::HeadType) == typeid(float));
|
||||
}
|
||||
|
||||
|
||||
void TypeListTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TypeListTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* TypeListTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TypeListTest");
|
||||
|
||||
CppUnit_addTest(pSuite, TypeListTest, testTypeListMacro);
|
||||
CppUnit_addTest(pSuite, TypeListTest, testTypeListTemplate);
|
||||
|
||||
return pSuite;
|
||||
}
|
60
Foundation/testsuite/src/TypeListTest.h
Normal file
60
Foundation/testsuite/src/TypeListTest.h
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// TypeListTest.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.h#1 $
|
||||
//
|
||||
// Definition of the TypeListTest class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef TypeListTest_INCLUDED
|
||||
#define TypeListTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class TypeListTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
TypeListTest(const std::string& name);
|
||||
~TypeListTest();
|
||||
|
||||
void testTypeListMacro();
|
||||
void testTypeListTemplate();
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // TypeListTest_INCLUDED
|
Loading…
x
Reference in New Issue
Block a user