/////////////////////////////////////////////////////////////////////////////// // Unit Test for Loki // // Copyright Terje Slettebų and Pavel Vozenilek 2002. // // Permission to use, copy, modify, and distribute this software for any // purpose is hereby granted without fee, provided that this copyright and // permissions notice appear in all copies and derivatives. // // This software is provided "as is" without express or implied warranty. // // Last update: September 16, 2002 /////////////////////////////////////////////////////////////////////////////// #ifndef TYPEMANIPTEST_H #define TYPEMANIPTEST_H #include #include "UnitTest.h" /////////////////////////////////////////////////////////////////////////////// // TypeManipTest /////////////////////////////////////////////////////////////////////////////// class TypeManipTest : public Test { public: TypeManipTest() : Test("TypeManip.h") {} virtual void execute(TestResult &result) { printName(result); using namespace Loki; bool r; r=Int2Type<1>::value==1; testAssert("Int2Type",r,result); r=SameType::OriginalType,char>::value; testAssert("Type2Type",r,result); r=SameType::Result,char>::value && SameType::Result,int>::value; testAssert("Select",r,result); r=Conversion::exists && Conversion::exists2Way && !Conversion::sameType && Conversion::exists && Conversion::exists2Way && Conversion::sameType && Conversion::exists && !Conversion::exists && !Conversion::exists && Conversion::exists && Conversion::exists && Conversion::exists && !Conversion::exists && !Conversion::exists && Conversion::exists && Conversion::exists && !Conversion::exists && !Conversion::exists && Conversion::exists && !Conversion::exists; testAssert("Conversion",r,result); r=SuperSubclass::value && SuperSubclass::value && SuperSubclass::value && !SuperSubclass::value && !SuperSubclass::value && !SuperSubclass::value; testAssert("SuperSubclass",r,result); r=SuperSubclassStrict::value && SuperSubclassStrict::value && !SuperSubclassStrict::value && !SuperSubclassStrict::value && !SuperSubclassStrict::value && !SuperSubclassStrict::value; testAssert("SuperSubclassStrict",r,result); r=LOKI_SUPERSUBCLASS(Base,Derived1) && LOKI_SUPERSUBCLASS(Base,Derived2) && LOKI_SUPERSUBCLASS(Base,Base) && !LOKI_SUPERSUBCLASS(Derived1,Base) && !LOKI_SUPERSUBCLASS(Derived2,Base) && !LOKI_SUPERSUBCLASS(void,Base); testAssert("LOKI_SUPERSUBCLASS",r,result); r=LOKI_SUPERSUBCLASS_STRICT(Base,Derived1) && LOKI_SUPERSUBCLASS_STRICT(Base,Derived2) && !LOKI_SUPERSUBCLASS_STRICT(Base,Base) && !LOKI_SUPERSUBCLASS_STRICT(Derived1,Base) && !LOKI_SUPERSUBCLASS_STRICT(Derived2,Base) && !LOKI_SUPERSUBCLASS_STRICT(void,Base); testAssert("LOKI_SUPERSUBCLASS_STRICT",r,result); std::cout << '\n'; } private: struct Base { char c; }; struct Derived1 : Base { char c; }; struct Derived2 : Derived1 { char c; }; } typeManipTest; #endif