Teuchos Package Browser (Single Doxygen Collection) Version of the Day
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef TEUCHOS_UNIT_TEST_HELPERS_HPP
00043 #define TEUCHOS_UNIT_TEST_HELPERS_HPP
00044 
00045 
00052 #include "Teuchos_UnitTestBase.hpp"
00053 #include "Teuchos_StaticSetupMacro.hpp"
00054 
00055 
00060 #define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME) \
00061   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00062   { \
00063   public: \
00064     TEST_GROUP##_##TEST_NAME##_UnitTest() \
00065       : Teuchos::UnitTestBase( #TEST_GROUP, #TEST_NAME ) \
00066     {} \
00067     virtual void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00068     virtual std::string unitTestFile() const { return __FILE__; } \
00069     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00070   }; \
00071   \
00072   TEST_GROUP##_##TEST_NAME##_UnitTest \
00073     instance_##TEST_GROUP##_##TEST_NAME##_UnitTest; \
00074   \
00075   void TEST_GROUP##_##TEST_NAME##_UnitTest::runUnitTestImpl( \
00076     Teuchos::FancyOStream &out, bool &success ) const \
00077 
00078 
00084 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE) \
00085   template<class TYPE> \
00086   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00087   { \
00088   public: \
00089     TEST_GROUP##_##TEST_NAME##_UnitTest(const std::string& typeName) \
00090       : Teuchos::UnitTestBase( std::string(#TEST_GROUP)+"_"+typeName, #TEST_NAME ) \
00091     {} \
00092     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00093     virtual std::string unitTestFile() const { return __FILE__; } \
00094     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00095   }; \
00096   \
00097   template<class TYPE> \
00098   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>::runUnitTestImpl( \
00099     Teuchos::FancyOStream &out, bool &success ) const \
00100 
00101 
00106 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, TYPE) \
00107   \
00108   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>; \
00109   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE> \
00110   instance_##TEST_GROUP##_##TYPE##_##TEST_NAME##_UnitTest(#TYPE);
00111 
00112 
00113 #ifdef HAVE_TEUCHOS_FLOAT
00114 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)\
00115     TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, float)
00116 #else
00117 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)
00118 #endif
00119 
00120 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)\
00121   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, double)
00122 
00123 #if defined(HAVE_TEUCHOS_COMPLEX) && defined(HAVE_TEUCHOS_FLOAT)
00124 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)\
00125      typedef std::complex<float> ComplexFloat; \
00126      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexFloat)
00127 #else
00128 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)
00129 #endif
00130 
00131 #ifdef HAVE_TEUCHOS_COMPLEX
00132 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)\
00133      typedef std::complex<double> ComplexDouble; \
00134      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexDouble)
00135 #else
00136 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00137 #endif
00138 
00139 
00145 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_REAL_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00146   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00147   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)
00148 
00149 
00154 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00155   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00156   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME) \
00157   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME) \
00158   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00159 
00160 
00166 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00167   template<class TYPE1, class TYPE2> \
00168   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00169   { \
00170   public: \
00171     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00172       const std::string& type1Name, \
00173       const std::string& type2Name \
00174        ) \
00175       :Teuchos::UnitTestBase( \
00176          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name, #TEST_NAME ) \
00177     {} \
00178     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00179     virtual std::string unitTestFile() const { return __FILE__; } \
00180     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00181   }; \
00182   \
00183   template<class TYPE1, class TYPE2> \
00184   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2>::runUnitTestImpl( \
00185     Teuchos::FancyOStream &out, bool &success ) const \
00186 
00187 
00191 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00192   \
00193   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 >; \
00194   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 > \
00195   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2);
00196 
00197 
00203 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00204   template<class TYPE1, class TYPE2, class TYPE3> \
00205   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00206   { \
00207   public: \
00208     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00209       const std::string& type1Name, \
00210       const std::string& type2Name, \
00211       const std::string& type3Name \
00212        ) \
00213       :Teuchos::UnitTestBase( \
00214          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name, #TEST_NAME ) \
00215     {} \
00216     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00217     virtual std::string unitTestFile() const { return __FILE__; } \
00218     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00219   }; \
00220   \
00221   template<class TYPE1, class TYPE2, class TYPE3> \
00222   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3>::runUnitTestImpl( \
00223     Teuchos::FancyOStream &out, bool &success ) const \
00224 
00225 
00230 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00231   \
00232   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 >; \
00233   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 > \
00234   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3);
00235 
00236 
00242 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00243   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00244   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00245   { \
00246   public: \
00247     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00248       const std::string& type1Name, \
00249       const std::string& type2Name, \
00250       const std::string& type3Name, \
00251       const std::string& type4Name \
00252        ) \
00253       :Teuchos::UnitTestBase( \
00254          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name+"_"+type4Name, #TEST_NAME ) \
00255     {} \
00256     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00257     virtual std::string unitTestFile() const { return __FILE__; } \
00258     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00259   }; \
00260   \
00261   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00262   void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3,TYPE4>::runUnitTestImpl( \
00263     Teuchos::FancyOStream &out, bool &success ) const \
00264 
00265 
00270 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00271   \
00272   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 >; \
00273   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 > \
00274   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TYPE4##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3,#TYPE4);
00275 
00276 
00277 #endif  // TEUCHOS_UNIT_TEST_HELPERS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines