Teuchos_UnitTestHelpers.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef TEUCHOS_UNIT_TEST_HELPERS_HPP
00030 #define TEUCHOS_UNIT_TEST_HELPERS_HPP
00031 
00032 
00039 #include "Teuchos_UnitTestBase.hpp"
00040 
00041 
00043 #define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME) \
00044   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00045   { \
00046   public: \
00047     TEST_GROUP##_##TEST_NAME##_UnitTest() \
00048       : Teuchos::UnitTestBase( #TEST_GROUP, #TEST_NAME ) \
00049     {} \
00050     virtual void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00051     virtual std::string unitTestFile() const { return __FILE__; } \
00052     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00053   }; \
00054   \
00055   TEST_GROUP##_##TEST_NAME##_UnitTest \
00056     instance_##TEST_GROUP##_##TEST_NAME##_UnitTest; \
00057   \
00058   void TEST_GROUP##_##TEST_NAME##_UnitTest::runUnitTestImpl( \
00059     Teuchos::FancyOStream &out, bool &success ) const \
00060 
00061 
00063 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE) \
00064   template<class TYPE> \
00065   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00066   { \
00067   public: \
00068     TEST_GROUP##_##TEST_NAME##_UnitTest(const std::string& typeName) \
00069       : Teuchos::UnitTestBase( std::string(#TEST_GROUP)+"_"+typeName, #TEST_NAME ) \
00070     {} \
00071     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00072     virtual std::string unitTestFile() const { return __FILE__; } \
00073     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00074   }; \
00075   \
00076   template<class TYPE> \
00077   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>::runUnitTestImpl( \
00078     Teuchos::FancyOStream &out, bool &success ) const \
00079 
00080 
00081 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, TYPE) \
00082   \
00083   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>; \
00084   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE> \
00085   instance_##TEST_GROUP##_##TYPE##_##TEST_NAME##_UnitTest(#TYPE);
00086 
00087 
00088 #ifdef HAVE_TEUCHOS_FLOAT
00089 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)\
00090     TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, float)
00091 #else
00092 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)
00093 #endif
00094 
00095 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)\
00096   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, double)
00097 
00098 #if defined(HAVE_TEUCHOS_COMPLEX) && defined(HAVE_TEUCHOS_FLOAT)
00099 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)\
00100      typedef std::complex<float> ComplexFloat; \
00101      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexFloat)
00102 #else
00103 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)
00104 #endif
00105 
00106 #ifdef HAVE_TEUCHOS_COMPLEX
00107 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)\
00108      typedef std::complex<double> ComplexDouble; \
00109      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexDouble)
00110 #else
00111 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00112 #endif
00113 
00114 
00118 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_REAL_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00119   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00120   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)
00121 
00122 
00124 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00125   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00126   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME) \
00127   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME) \
00128   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00129 
00130 
00132 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00133   template<class TYPE1, class TYPE2> \
00134   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00135   { \
00136   public: \
00137     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00138       const std::string& type1Name, \
00139       const std::string& type2Name \
00140        ) \
00141       :Teuchos::UnitTestBase( \
00142          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name, #TEST_NAME ) \
00143     {} \
00144     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00145     virtual std::string unitTestFile() const { return __FILE__; } \
00146     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00147   }; \
00148   \
00149   template<class TYPE1, class TYPE2> \
00150   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2>::runUnitTestImpl( \
00151     Teuchos::FancyOStream &out, bool &success ) const \
00152 
00153 
00154 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00155   \
00156   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 >; \
00157   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 > \
00158   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2);
00159 
00161 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00162   template<class TYPE1, class TYPE2, class TYPE3> \
00163   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00164   { \
00165   public: \
00166     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00167       const std::string& type1Name, \
00168       const std::string& type2Name, \
00169       const std::string& type3Name \
00170        ) \
00171       :Teuchos::UnitTestBase( \
00172          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name, #TEST_NAME ) \
00173     {} \
00174     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00175     virtual std::string unitTestFile() const { return __FILE__; } \
00176     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00177   }; \
00178   \
00179   template<class TYPE1, class TYPE2, class TYPE3> \
00180   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3>::runUnitTestImpl( \
00181     Teuchos::FancyOStream &out, bool &success ) const \
00182 
00183 
00184 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00185   \
00186   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 >; \
00187   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 > \
00188   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3);
00189 
00191 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00192   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00193   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00194   { \
00195   public: \
00196     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00197       const std::string& type1Name, \
00198       const std::string& type2Name, \
00199       const std::string& type3Name, \
00200       const std::string& type4Name \
00201        ) \
00202       :Teuchos::UnitTestBase( \
00203          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name+"_"+type4Name, #TEST_NAME ) \
00204     {} \
00205     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00206     virtual std::string unitTestFile() const { return __FILE__; } \
00207     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00208   }; \
00209   \
00210   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00211   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3,TYPE4>::runUnitTestImpl( \
00212     Teuchos::FancyOStream &out, bool &success ) const \
00213 
00214 
00215 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00216   \
00217   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 >; \
00218   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 > \
00219   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TYPE4##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3,#TYPE4);
00220 
00221 
00241 #define TEUCHOS_STATIC_SETUP() \
00242   class StaticSetup { \
00243   public: \
00244     StaticSetup(); \
00245   } staticSetup; \
00246   \
00247   StaticSetup::StaticSetup()
00248 
00249 
00250 #endif  // TEUCHOS_UNIT_TEST_HELPERS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 09:57:44 2011 for Teuchos - Trilinos Tools Package by  doxygen 1.6.3