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 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)\
00089   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, float)
00090 
00091 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)\
00092   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, double)
00093 
00094 #ifdef HAVE_TEUCHOS_COMPLEX
00095 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)\
00096      typedef std::complex<float> ComplexFloat; \
00097      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexFloat)
00098 #else
00099 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)
00100 #endif
00101 
00102 #ifdef HAVE_TEUCHOS_COMPLEX
00103 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)\
00104      typedef std::complex<double> ComplexDouble; \
00105      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexDouble)
00106 #else
00107 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00108 #endif
00109 
00110 
00112 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00113   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00114   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME) \
00115   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME) \
00116   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00117 
00118 
00120 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00121   template<class TYPE1, class TYPE2> \
00122   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00123   { \
00124   public: \
00125     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00126       const std::string& type1Name, \
00127       const std::string& type2Name \
00128        ) \
00129       :Teuchos::UnitTestBase( \
00130          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name, #TEST_NAME ) \
00131     {} \
00132     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00133     virtual std::string unitTestFile() const { return __FILE__; } \
00134     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00135   }; \
00136   \
00137   template<class TYPE1, class TYPE2> \
00138   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2>::runUnitTestImpl( \
00139     Teuchos::FancyOStream &out, bool &success ) const \
00140 
00141 
00142 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00143   \
00144   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 >; \
00145   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 > \
00146   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2);
00147 
00148 
00168 #define TEUCHOS_STATIC_SETUP() \
00169   class StaticSetup { \
00170   public: \
00171     StaticSetup(); \
00172   } staticSetup; \
00173   \
00174   StaticSetup::StaticSetup()
00175 
00176 
00177 #endif  // TEUCHOS_UNIT_TEST_HELPERS_HPP

Generated on Wed May 12 21:40:33 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7