new version of TypeTest2 from Kalle Rutanen
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@260 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
af99695527
commit
62de511210
1 changed files with 301 additions and 108 deletions
|
@ -1,6 +1,6 @@
|
||||||
// Loki TypeTraits test program
|
// Loki TypeTraits test program
|
||||||
// Kalle Rutanen
|
// Kalle Rutanen
|
||||||
// 9.9.2005
|
// 25.9.2005
|
||||||
//
|
//
|
||||||
// Some type sets
|
// Some type sets
|
||||||
// --------------
|
// --------------
|
||||||
|
@ -104,12 +104,9 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <typeinfo>
|
#include <vector>
|
||||||
|
|
||||||
#define ENABLE_ADDITIONAL_TYPETRAITS
|
#include "loki/TypeTraits.h"
|
||||||
|
|
||||||
|
|
||||||
#include <loki/TypeTraits.h>
|
|
||||||
|
|
||||||
// Macros for testing isX variables
|
// Macros for testing isX variables
|
||||||
|
|
||||||
|
@ -129,9 +126,9 @@
|
||||||
|
|
||||||
#define TEST_TYPE_HELP2(type, rightType, cond) \
|
#define TEST_TYPE_HELP2(type, rightType, cond) \
|
||||||
{ \
|
{ \
|
||||||
const std::type_info& info = typeid(Loki::TypeTraits<type>::cond); \
|
bool testResult = Loki::IsSameType<rightType, \
|
||||||
bool testResult = Loki::IsSameType<rightType, Loki::TypeTraits<type>::cond>::value; \
|
Loki::TypeTraits<type>::cond>::value; \
|
||||||
testType(testResult, #cond, #type, info.name(), #rightType); \
|
testType(testResult, #cond, #type, #rightType); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// This macro is needed as an intermediate step to print CONDITION right
|
// This macro is needed as an intermediate step to print CONDITION right
|
||||||
|
@ -146,13 +143,16 @@
|
||||||
// TypeTraitsTest2
|
// TypeTraitsTest2
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class TypeTraitsTest2: public Test
|
class TypeTraitsTest2 : public Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TypeTraitsTest2()
|
TypeTraitsTest2()
|
||||||
: Test("TypeTraits.h"),
|
: Test("TypeTraits.h"),
|
||||||
testedConditions_(0),
|
testedConditions_(0),
|
||||||
erroneousConditions_(0)
|
erroneousConditions_(0),
|
||||||
|
groupErrors_(0),
|
||||||
|
textBuffer_(),
|
||||||
|
groupName_()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,10 +161,12 @@ public:
|
||||||
private:
|
private:
|
||||||
class A{};
|
class A{};
|
||||||
|
|
||||||
|
void testBegin(const std::string& groupName);
|
||||||
|
void testEnd();
|
||||||
|
|
||||||
void testCount(bool result);
|
void testCount(bool result);
|
||||||
void testType(bool result, std::string conditionText,
|
void testType(bool result, std::string conditionText,
|
||||||
std::string typeText,
|
std::string typeText,
|
||||||
std::string deducedTypeText,
|
|
||||||
std::string rightTypeText);
|
std::string rightTypeText);
|
||||||
void testCondition(bool result, bool answer, std::string text);
|
void testCondition(bool result, bool answer, std::string text);
|
||||||
|
|
||||||
|
@ -175,21 +177,31 @@ private:
|
||||||
void testPointer();
|
void testPointer();
|
||||||
void testReference();
|
void testReference();
|
||||||
void testMemberPointer();
|
void testMemberPointer();
|
||||||
void testFunctionPointer();
|
|
||||||
void testMemberFunctionPointer();
|
|
||||||
void testFunction();
|
void testFunction();
|
||||||
|
void testFunctionPointer();
|
||||||
|
void testMemberFunctionPointer();
|
||||||
|
|
||||||
void testParameterType();
|
void testParameterType();
|
||||||
void testReferredType();
|
void testReferredType();
|
||||||
void testPointeeType();
|
void testPointeeType();
|
||||||
|
void testNonConstType();
|
||||||
|
void testNonVolatileType();
|
||||||
|
void testUnqualifiedType();
|
||||||
|
|
||||||
unsigned int testedConditions_;
|
unsigned int testedConditions_;
|
||||||
unsigned int erroneousConditions_;
|
unsigned int erroneousConditions_;
|
||||||
|
unsigned int groupErrors_;
|
||||||
|
std::vector<std::string> textBuffer_;
|
||||||
|
std::string groupName_;
|
||||||
|
|
||||||
} typeTraitsTest2;
|
} typeTraitsTest2;
|
||||||
|
|
||||||
inline void TypeTraitsTest2::execute(TestResult &result)
|
inline void TypeTraitsTest2::execute(TestResult &result)
|
||||||
{
|
{
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
printName(result);
|
printName(result);
|
||||||
|
|
||||||
testIntegral();
|
testIntegral();
|
||||||
|
@ -199,22 +211,58 @@ inline void TypeTraitsTest2::execute(TestResult &result)
|
||||||
testPointer();
|
testPointer();
|
||||||
testReference();
|
testReference();
|
||||||
testMemberPointer();
|
testMemberPointer();
|
||||||
testFunctionPointer();
|
|
||||||
testMemberFunctionPointer();
|
|
||||||
testFunction();
|
|
||||||
testParameterType();
|
testParameterType();
|
||||||
testReferredType();
|
testReferredType();
|
||||||
testPointeeType();
|
testPointeeType();
|
||||||
|
testNonConstType();
|
||||||
|
testNonVolatileType();
|
||||||
|
testUnqualifiedType();
|
||||||
|
|
||||||
|
testFunction();
|
||||||
|
testFunctionPointer();
|
||||||
|
testMemberFunctionPointer();
|
||||||
|
|
||||||
bool r = erroneousConditions_ == 0;
|
bool r = erroneousConditions_ == 0;
|
||||||
|
|
||||||
std::cout << "Tested " << testedConditions_
|
cout << endl << "Tested " << testedConditions_
|
||||||
<< " conditions of which " << erroneousConditions_
|
<< " conditions of which " << erroneousConditions_
|
||||||
<< " were erroneous" << std::endl;
|
<< " were erroneous" << endl;
|
||||||
|
|
||||||
testAssert("TypeTraits2",r,result);
|
testAssert("TypeTraits",r,result);
|
||||||
|
|
||||||
std::cout << std::endl;
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testBegin(const std::string& groupName)
|
||||||
|
{
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
textBuffer_.clear();
|
||||||
|
groupErrors_ = 0;
|
||||||
|
groupName_ = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testEnd()
|
||||||
|
{
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
if (groupErrors_ > 0)
|
||||||
|
{
|
||||||
|
cout << endl;
|
||||||
|
cout << groupName_ << ": " << groupErrors_
|
||||||
|
<< " error(s) found." << endl;
|
||||||
|
cout << "---------------------------"
|
||||||
|
<< "-----------------------" << endl;
|
||||||
|
|
||||||
|
for (int i = 0;i < textBuffer_.size();++i)
|
||||||
|
{
|
||||||
|
cout << textBuffer_[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textBuffer_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testCount(bool result)
|
inline void TypeTraitsTest2::testCount(bool result)
|
||||||
|
@ -222,34 +270,66 @@ inline void TypeTraitsTest2::testCount(bool result)
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
++erroneousConditions_;
|
++erroneousConditions_;
|
||||||
|
++groupErrors_;
|
||||||
}
|
}
|
||||||
|
|
||||||
++testedConditions_;
|
++testedConditions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testType(bool result, std::string conditionText,
|
inline void TypeTraitsTest2::testType(bool result,
|
||||||
std::string typeText,
|
std::string conditionText,
|
||||||
std::string deducedTypeText,
|
std::string typeText,
|
||||||
std::string rightTypeText)
|
std::string rightTypeText)
|
||||||
{
|
{
|
||||||
|
using std::string;
|
||||||
|
|
||||||
testCount(result);
|
testCount(result);
|
||||||
|
|
||||||
|
string message;
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
std::cout << "TypeTraits<" << typeText << ">::"
|
message = string("FAILED:\n");
|
||||||
<< conditionText << " -> " << deducedTypeText << std::endl;
|
|
||||||
std::cout << " Expected " << rightTypeText << std::endl;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = string("PASSED:\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
message += string(" TypeTraits<") + typeText + string(">::")
|
||||||
|
+ conditionText + string("\n");
|
||||||
|
message += string(" Expected: ") + rightTypeText + string("\n");
|
||||||
|
|
||||||
|
textBuffer_.push_back(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testCondition(bool result, bool answer, std::string text)
|
inline void TypeTraitsTest2::testCondition(
|
||||||
|
bool result, bool answer, std::string text)
|
||||||
{
|
{
|
||||||
testCount(result == answer);
|
testCount(result == answer);
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
string message;
|
||||||
|
|
||||||
if (result != answer)
|
if (result != answer)
|
||||||
{
|
{
|
||||||
std::cout << text << " == " << result << std::endl;
|
message = string("FAILED:\n");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = string("PASSED:\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
message += string(" ") + text + string("\n");
|
||||||
|
message +=
|
||||||
|
string(" Result: ") +
|
||||||
|
string(result ? "true" : "false") + string("\n");
|
||||||
|
message +=
|
||||||
|
string(" Expected: ") +
|
||||||
|
string(answer ? "true" : "false") + string("\n");
|
||||||
|
|
||||||
|
textBuffer_.push_back(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testIntegral()
|
inline void TypeTraitsTest2::testIntegral()
|
||||||
|
@ -257,6 +337,8 @@ inline void TypeTraitsTest2::testIntegral()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isIntegral
|
#define CONDITION isIntegral
|
||||||
|
|
||||||
|
testBegin("isIntegral");
|
||||||
|
|
||||||
PASS(bool);
|
PASS(bool);
|
||||||
PASS(char);
|
PASS(char);
|
||||||
PASS(wchar_t);
|
PASS(wchar_t);
|
||||||
|
@ -280,6 +362,8 @@ inline void TypeTraitsTest2::testIntegral()
|
||||||
FAIL(int(*)(int, float, ...));
|
FAIL(int(*)(int, float, ...));
|
||||||
FAIL(int (A::*)());
|
FAIL(int (A::*)());
|
||||||
FAIL(int (A::*)(int, float, ...));
|
FAIL(int (A::*)(int, float, ...));
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testFloat()
|
inline void TypeTraitsTest2::testFloat()
|
||||||
|
@ -287,6 +371,8 @@ inline void TypeTraitsTest2::testFloat()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isFloat
|
#define CONDITION isFloat
|
||||||
|
|
||||||
|
testBegin("isFloat");
|
||||||
|
|
||||||
PASS(float);
|
PASS(float);
|
||||||
PASS(double);
|
PASS(double);
|
||||||
PASS(long double);
|
PASS(long double);
|
||||||
|
@ -303,6 +389,8 @@ inline void TypeTraitsTest2::testFloat()
|
||||||
FAIL(float(*)(int, float, ...));
|
FAIL(float(*)(int, float, ...));
|
||||||
FAIL(float (A::*)());
|
FAIL(float (A::*)());
|
||||||
FAIL(float (A::*)(int, float, ...));
|
FAIL(float (A::*)(int, float, ...));
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testConst()
|
inline void TypeTraitsTest2::testConst()
|
||||||
|
@ -310,6 +398,8 @@ inline void TypeTraitsTest2::testConst()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isConst
|
#define CONDITION isConst
|
||||||
|
|
||||||
|
testBegin("isConst");
|
||||||
|
|
||||||
PASS(const volatile int);
|
PASS(const volatile int);
|
||||||
PASS(int* const volatile);
|
PASS(int* const volatile);
|
||||||
PASS(int (* const volatile)());
|
PASS(int (* const volatile)());
|
||||||
|
@ -328,6 +418,8 @@ inline void TypeTraitsTest2::testConst()
|
||||||
FAIL(const int(*)(int, float, ...));
|
FAIL(const int(*)(int, float, ...));
|
||||||
FAIL(const int (A::*)() const);
|
FAIL(const int (A::*)() const);
|
||||||
FAIL(const int (A::*)(int, float, ...) const);
|
FAIL(const int (A::*)(int, float, ...) const);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testVolatile()
|
inline void TypeTraitsTest2::testVolatile()
|
||||||
|
@ -335,6 +427,8 @@ inline void TypeTraitsTest2::testVolatile()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isVolatile
|
#define CONDITION isVolatile
|
||||||
|
|
||||||
|
testBegin("isVolatile");
|
||||||
|
|
||||||
PASS(const volatile int);
|
PASS(const volatile int);
|
||||||
PASS(int* const volatile);
|
PASS(int* const volatile);
|
||||||
PASS(int (* const volatile)());
|
PASS(int (* const volatile)());
|
||||||
|
@ -355,6 +449,8 @@ inline void TypeTraitsTest2::testVolatile()
|
||||||
FAIL(volatile int (A::*)(int, float, ...) volatile);
|
FAIL(volatile int (A::*)(int, float, ...) volatile);
|
||||||
FAIL(volatile int(*)(int, float));
|
FAIL(volatile int(*)(int, float));
|
||||||
FAIL(volatile int (A::*)(int, float) volatile);
|
FAIL(volatile int (A::*)(int, float) volatile);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testReference()
|
inline void TypeTraitsTest2::testReference()
|
||||||
|
@ -362,6 +458,8 @@ inline void TypeTraitsTest2::testReference()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isReference
|
#define CONDITION isReference
|
||||||
|
|
||||||
|
testBegin("isReference");
|
||||||
|
|
||||||
PASS(const volatile int&);
|
PASS(const volatile int&);
|
||||||
PASS(void (*const volatile&)(int, float));
|
PASS(void (*const volatile&)(int, float));
|
||||||
PASS(void (&)(int, float));
|
PASS(void (&)(int, float));
|
||||||
|
@ -371,6 +469,8 @@ inline void TypeTraitsTest2::testReference()
|
||||||
|
|
||||||
FAIL(int);
|
FAIL(int);
|
||||||
FAIL(void);
|
FAIL(void);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testPointer()
|
inline void TypeTraitsTest2::testPointer()
|
||||||
|
@ -378,24 +478,20 @@ inline void TypeTraitsTest2::testPointer()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isPointer
|
#define CONDITION isPointer
|
||||||
|
|
||||||
|
testBegin("isPointer");
|
||||||
|
|
||||||
PASS(int* const volatile);
|
PASS(int* const volatile);
|
||||||
PASS(void (* const volatile)());
|
PASS(void (* const volatile)());
|
||||||
PASS(void (* const volatile)(int, float));
|
PASS(void (* const volatile)(int, float));
|
||||||
PASS(void (* const volatile)(int, float, ...));
|
PASS(void (* const volatile)(int, float, ...));
|
||||||
|
|
||||||
|
|
||||||
PASS(void (A::* const volatile)() const volatile);
|
|
||||||
PASS(void (A::* const volatile)(int, float) const volatile);
|
|
||||||
PASS(void (A::* const volatile)(int, float, ...) const volatile);
|
|
||||||
PASS(int A::* const volatile);
|
|
||||||
|
|
||||||
|
|
||||||
PASS(const volatile int** const volatile ** const * const volatile);
|
PASS(const volatile int** const volatile ** const * const volatile);
|
||||||
PASS(int* const volatile&);
|
PASS(int* const volatile&);
|
||||||
|
|
||||||
FAIL(int);
|
FAIL(int);
|
||||||
FAIL(int&);
|
FAIL(int&);
|
||||||
FAIL(void);
|
FAIL(void);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testMemberPointer()
|
inline void TypeTraitsTest2::testMemberPointer()
|
||||||
|
@ -403,31 +499,106 @@ inline void TypeTraitsTest2::testMemberPointer()
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isMemberPointer
|
#define CONDITION isMemberPointer
|
||||||
|
|
||||||
|
testBegin("isMemberPointer");
|
||||||
|
|
||||||
PASS(int A::* const volatile);
|
PASS(int A::* const volatile);
|
||||||
PASS(const volatile int A::* const volatile);
|
|
||||||
|
|
||||||
|
|
||||||
// Pointer to member functions
|
|
||||||
PASS(int (A::* )() const);
|
|
||||||
PASS(int (A::* const volatile)() const volatile);
|
PASS(int (A::* const volatile)() const volatile);
|
||||||
PASS(int (A::* const volatile)(int, float) const volatile);
|
PASS(int (A::* const volatile)(int, float) const volatile);
|
||||||
PASS(int (A::* const volatile&)(int, float) const volatile);
|
PASS(int (A::* const volatile&)(int, float) const volatile);
|
||||||
PASS(int (A::* const volatile)(int, float, ...) const volatile);
|
PASS(int (A::* const volatile)(int, float, ...) const volatile);
|
||||||
PASS(int (A::* const volatile&)(int, float, ...) const volatile);
|
PASS(int (A::* const volatile&)(int, float, ...) const volatile);
|
||||||
|
|
||||||
|
|
||||||
FAIL(int);
|
FAIL(int);
|
||||||
FAIL(void);
|
FAIL(void);
|
||||||
FAIL(void*);
|
FAIL(void*);
|
||||||
FAIL(void(*)());
|
FAIL(void(*)());
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testParameterType()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION ParameterType
|
||||||
|
|
||||||
|
testBegin("ParameterType");
|
||||||
|
|
||||||
|
TEST_TYPE(int, int);
|
||||||
|
TEST_TYPE(const volatile int, const volatile int);
|
||||||
|
TEST_TYPE(const volatile int&, const volatile int&);
|
||||||
|
TEST_TYPE(void, Loki::NullType);
|
||||||
|
TEST_TYPE(void*, void*);
|
||||||
|
TEST_TYPE(void* const volatile, void* const volatile);
|
||||||
|
TEST_TYPE(void* const volatile&, void* const volatile&);
|
||||||
|
TEST_TYPE(const volatile A, const volatile A&);
|
||||||
|
TEST_TYPE(A, const A&);
|
||||||
|
TEST_TYPE(A&, A&);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testReferredType()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION ReferredType
|
||||||
|
|
||||||
|
testBegin("ReferredType");
|
||||||
|
|
||||||
|
TEST_TYPE(const volatile int&, const volatile int);
|
||||||
|
TEST_TYPE(void* const volatile&, void* const volatile);
|
||||||
|
TEST_TYPE(void (&)(), void());
|
||||||
|
TEST_TYPE(void (&)(int, float, ...), void(int, float, ...));
|
||||||
|
TEST_TYPE(int (*)(), int (*)());
|
||||||
|
TEST_TYPE(int (*&)(int, float, ...), int (*)(int, float, ...));
|
||||||
|
TEST_TYPE(int (A::*&)() const volatile, int (A::*)() const volatile);
|
||||||
|
TEST_TYPE(int (A::*&)(int, float, ...) const volatile,
|
||||||
|
int (A::*)(int, float, ...) const volatile);
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testPointeeType()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION PointeeType
|
||||||
|
|
||||||
|
testBegin("PointeeType");
|
||||||
|
|
||||||
|
TEST_TYPE(void, Loki::NullType);
|
||||||
|
TEST_TYPE(void*, void);
|
||||||
|
TEST_TYPE(const volatile int*, const volatile int);
|
||||||
|
TEST_TYPE(const volatile int* const volatile&,
|
||||||
|
const volatile int);
|
||||||
|
TEST_TYPE(void(*)(int, float), void(int, float));
|
||||||
|
TEST_TYPE(void(int, float), Loki::NullType);
|
||||||
|
TEST_TYPE(void(*&)(int, float), void(int, float));
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testFunction()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION isFunction
|
||||||
|
|
||||||
|
testBegin("isFunction");
|
||||||
|
|
||||||
|
PASS(void());
|
||||||
|
PASS(void(int, float, ...));
|
||||||
|
PASS(void(&)(int, float, ...));
|
||||||
|
PASS(void(int, float));
|
||||||
|
PASS(void(&)());
|
||||||
|
PASS(void(&)(int, float));
|
||||||
|
PASS(int(&)(int, float));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testFunctionPointer()
|
inline void TypeTraitsTest2::testFunctionPointer()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_ADDITIONAL_TYPETRAITS
|
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isFunctionPointer
|
#define CONDITION isFunctionPointer
|
||||||
|
|
||||||
|
testBegin("isFunctionPointer");
|
||||||
|
|
||||||
PASS(void (*)());
|
PASS(void (*)());
|
||||||
FAIL(void (A::* const volatile)());
|
FAIL(void (A::* const volatile)());
|
||||||
FAIL(void (A::* const volatile)() const);
|
FAIL(void (A::* const volatile)() const);
|
||||||
|
@ -446,16 +617,15 @@ inline void TypeTraitsTest2::testFunctionPointer()
|
||||||
FAIL(void);
|
FAIL(void);
|
||||||
FAIL(void*);
|
FAIL(void*);
|
||||||
FAIL(int A::*);
|
FAIL(int A::*);
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testMemberFunctionPointer()
|
inline void TypeTraitsTest2::testMemberFunctionPointer()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_ADDITIONAL_TYPETRAITS
|
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION isMemberFunctionPointer
|
#define CONDITION isMemberFunctionPointer
|
||||||
|
|
||||||
|
testBegin("isMemberFunctionPointer");
|
||||||
|
|
||||||
PASS(void (A::* const volatile)());
|
PASS(void (A::* const volatile)());
|
||||||
PASS(void (A::* const volatile)() const);
|
PASS(void (A::* const volatile)() const);
|
||||||
PASS(void (A::* const volatile)() volatile);
|
PASS(void (A::* const volatile)() volatile);
|
||||||
|
@ -473,74 +643,97 @@ inline void TypeTraitsTest2::testMemberFunctionPointer()
|
||||||
FAIL(void);
|
FAIL(void);
|
||||||
FAIL(void*);
|
FAIL(void*);
|
||||||
FAIL(int A::*);
|
FAIL(int A::*);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testFunction()
|
inline void TypeTraitsTest2::testNonConstType()
|
||||||
{
|
|
||||||
#ifdef ENABLE_ADDITIONAL_TYPETRAITS
|
|
||||||
#undef CONDITION
|
|
||||||
#define CONDITION isFunction
|
|
||||||
|
|
||||||
PASS(void());
|
|
||||||
PASS(void(int, float, ...));
|
|
||||||
PASS(void(&)(int, float, ...));
|
|
||||||
PASS(void(int, float));
|
|
||||||
PASS(void(&)());
|
|
||||||
PASS(void(&)(int, float));
|
|
||||||
PASS(int(&)(int, float));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testParameterType()
|
|
||||||
{
|
{
|
||||||
#undef CONDITION
|
#undef CONDITION
|
||||||
#define CONDITION ParameterType
|
#define CONDITION NonConstType
|
||||||
|
|
||||||
TEST_TYPE(int, int);
|
testBegin("NonConstType");
|
||||||
TEST_TYPE(const volatile int, const volatile int);
|
|
||||||
TEST_TYPE(const volatile int&, const volatile int&);
|
TEST_TYPE(void, void);
|
||||||
TEST_TYPE(void, Loki::NullType);
|
|
||||||
TEST_TYPE(void*, void*);
|
TEST_TYPE(const int, int);
|
||||||
TEST_TYPE(void* const volatile, void* const volatile);
|
TEST_TYPE(const volatile int, volatile int);
|
||||||
TEST_TYPE(void* const volatile&, void* const volatile&);
|
TEST_TYPE(
|
||||||
TEST_TYPE(const volatile A, const volatile A&);
|
const volatile int* const volatile,
|
||||||
TEST_TYPE(A&, A&);
|
const volatile int* volatile);
|
||||||
|
TEST_TYPE(int(int, float,...), int(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(* const volatile)(int, float,...),
|
||||||
|
int(* volatile)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(A::* const volatile)(int, float,...),
|
||||||
|
int(A::* volatile)(int, float, ...));
|
||||||
|
|
||||||
|
// Reference versions
|
||||||
|
|
||||||
TEST_TYPE(A, const A&);
|
TEST_TYPE(const int&, int&);
|
||||||
}
|
TEST_TYPE(const volatile int&, volatile int&);
|
||||||
|
TEST_TYPE(int&, int&);
|
||||||
inline void TypeTraitsTest2::testReferredType()
|
|
||||||
{
|
|
||||||
#undef CONDITION
|
|
||||||
#define CONDITION ReferredType
|
|
||||||
|
|
||||||
TEST_TYPE(const volatile int&, const volatile int);
|
|
||||||
TEST_TYPE(void* const volatile&, void* const volatile);
|
|
||||||
TEST_TYPE(void (&)(), void());
|
|
||||||
TEST_TYPE(void (&)(int, float, ...), void(int, float, ...));
|
|
||||||
TEST_TYPE(int (*)(), int (*)());
|
|
||||||
TEST_TYPE(int (*&)(int, float, ...), int (*)(int, float, ...));
|
|
||||||
TEST_TYPE(int (A::*&)() const volatile, int (A::*)() const volatile);
|
|
||||||
TEST_TYPE(int (A::*&)(int, float, ...) const volatile, int (A::*)(int, float, ...) const volatile);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void TypeTraitsTest2::testPointeeType()
|
|
||||||
{
|
|
||||||
#undef CONDITION
|
|
||||||
#define CONDITION PointeeType
|
|
||||||
|
|
||||||
TEST_TYPE(void, Loki::NullType);
|
|
||||||
TEST_TYPE(void*, void);
|
|
||||||
TEST_TYPE(const volatile int*, const volatile int);
|
|
||||||
|
|
||||||
TEST_TYPE(
|
TEST_TYPE(
|
||||||
const volatile int* const volatile&,
|
const volatile int* const volatile&,
|
||||||
const volatile int);
|
const volatile int* volatile&);
|
||||||
|
TEST_TYPE(int(&)(int, float,...), int(&)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(* const volatile&)(int, float,...),
|
||||||
|
int(* volatile&)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(A::* const volatile&)(int, float,...),
|
||||||
|
int(A::* volatile&)(int, float, ...));
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testNonVolatileType()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION NonVolatileType
|
||||||
|
|
||||||
|
testBegin("NonVolatileType");
|
||||||
|
|
||||||
|
TEST_TYPE(void, void);
|
||||||
|
|
||||||
|
TEST_TYPE(volatile int, int);
|
||||||
|
TEST_TYPE(const volatile int, const int);
|
||||||
|
TEST_TYPE(
|
||||||
|
const volatile int* const volatile,
|
||||||
|
const volatile int* const);
|
||||||
|
TEST_TYPE(int(int, float,...), int(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(* const volatile)(int, float,...),
|
||||||
|
int(* const)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(A::* const volatile)(int, float,...),
|
||||||
|
int(A::* const)(int, float, ...));
|
||||||
|
|
||||||
|
// Reference versions
|
||||||
|
|
||||||
TEST_TYPE(void(*)(int, float), void(int, float));
|
TEST_TYPE(volatile int&, int&);
|
||||||
TEST_TYPE(void(int, float), Loki::NullType);
|
TEST_TYPE(const volatile int&, const int&);
|
||||||
TEST_TYPE(void(*&)(int, float), void(int, float));
|
TEST_TYPE(int&, int&);
|
||||||
|
TEST_TYPE(
|
||||||
|
const volatile int* const volatile&,
|
||||||
|
const volatile int* const&);
|
||||||
|
TEST_TYPE(int(&)(int, float,...), int(&)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(* const volatile&)(int, float,...),
|
||||||
|
int(* const&)(int, float, ...));
|
||||||
|
TEST_TYPE(
|
||||||
|
int(A::* const volatile&)(int, float,...),
|
||||||
|
int(A::* const&)(int, float, ...));
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void TypeTraitsTest2::testUnqualifiedType()
|
||||||
|
{
|
||||||
|
#undef CONDITION
|
||||||
|
#define CONDITION UnqualifiedType
|
||||||
|
|
||||||
|
testBegin("UnqualifiedType");
|
||||||
|
testEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue