/////////////////////////////////////////////////////////////////////////////// // 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 SEQUENCETEST_H #define SEQUENCETEST_H #include /////////////////////////////////////////////////////////////////////////////// // SequenceTest /////////////////////////////////////////////////////////////////////////////// class SequenceTest : public Test { public: SequenceTest() : Test("Sequence.h") {} virtual void execute(TestResult &result) { printName(result); using namespace Loki; using namespace Loki::TL; typedef Seq::Type CharList; typedef Seq::Type CharIntDoubleList; typedef Seq::Type CharIntDoubleCharList; typedef Seq::Type BaseDerived1Derived2List; typedef Seq::Type Derived2Derived1BaseList; typedef Seq::Type BaseDerived1BaseDerived2List; typedef Seq::Type Derived1BaseDerived1Derived2List; bool r; r=Length::value==0 && Length::value==1 && Length::value==3; testAssert("Length",r,result); r=SameType::Result,char>::value && SameType::Result,double>::value; testAssert("TypeAt",r,result); #if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300) // TypeAtNonStrict works like TypeAt on MSVC 6.0 r=SameType::Result,NullType>::value && SameType::Result,char>::value && SameType::Result,double>::value && SameType::Result,NullType>::value && SameType::Result,long>::value; testAssert("TypeAtNonStrict",r,result); #else testAssert("TypeAtNonStrict",false,result,false); #endif r=IndexOf::value==-1 && IndexOf::value==0 && IndexOf::value==2 && IndexOf::value==-1; testAssert("IndexOf",r,result); #if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300) // Append, Erase, EraseAll, NoDuplicates, Replace, ReplaceAll, Reverse, // MostDerived and DerivedToFront doesn't work on MSVC 6.0 r=SameType::Result,NullType>::value && SameType::Result,Seq::Type>::value && SameType::Result,CharList>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value; testAssert("Append",r,result); r=SameType::Result,NullType>::value && SameType::Result,NullType>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value; testAssert("Erase",r,result); r=SameType::Result,NullType>::value && SameType::Result,NullType>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value; testAssert("EraseAll",r,result); r=SameType::Result,NullType>::value && SameType::Result,CharList>::value && SameType::Result,CharIntDoubleList>::value && SameType::Result,CharIntDoubleList>::value; testAssert("NoDuplicates",r,result); r=SameType::Result,NullType>::value && SameType::Result,Seq::Type>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value && SameType::Result,CharIntDoubleList>::value && SameType::Result,Seq::Type>::value; testAssert("Replace",r,result); r=SameType::Result,NullType>::value && SameType::Result,Seq::Type>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value && SameType::Result,CharIntDoubleList>::value && SameType::Result,Seq::Type>::value; testAssert("ReplaceAll",r,result); r=SameType::Result,NullType>::value && SameType::Result,CharList>::value && SameType::Result,Seq::Type>::value; testAssert("Reverse",r,result); r=SameType::Result,Base>::value && SameType::Result,Derived2>::value && SameType::Result,Derived2>::value && SameType::Result,Derived2>::value && SameType::Result,Derived2>::value && SameType::Result,Derived2>::value && SameType::Result,Derived2>::value; testAssert("MostDerived",r,result); r=SameType::Result,NullType>::value && SameType::Result,CharList>::value && SameType::Result,CharIntDoubleList>::value && SameType::Result,CharIntDoubleCharList>::value && SameType::Result,Derived2Derived1BaseList>::value && SameType::Result,Derived2Derived1BaseList>::value && SameType::Result,Seq::Type>::value && SameType::Result,Seq::Type>::value; testAssert("DerivedToFront",r,result); #else testAssert("Append",false,result,false); testAssert("Erase",false,result,false); testAssert("EraseAll",false,result,false); testAssert("NoDuplicates",false,result,false); testAssert("Replace",false,result,false); testAssert("Reverse",false,result,false); testAssert("MostDerived",false,result,false); testAssert("DerivedToFront",false,result,false); #endif std::cout << '\n'; } private: struct Base { char c; }; struct Derived1 : Base { char c; }; struct Derived2 : Derived1 { char c; }; } sequenceTest; #endif