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 
00057 #include "Teuchos_UnitTestBase.hpp"
00058 #include "Teuchos_StaticSetupMacro.hpp"
00059 
00060 
00083 #define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME) \
00084   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00085         { \
00086   public: \
00087     TEST_GROUP##_##TEST_NAME##_UnitTest() \
00088       : Teuchos::UnitTestBase( #TEST_GROUP, #TEST_NAME ) \
00089     {} \
00090     virtual void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00091     virtual std::string unitTestFile() const { return __FILE__; } \
00092     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00093   }; \
00094   \
00095   TEST_GROUP##_##TEST_NAME##_UnitTest \
00096     instance_##TEST_GROUP##_##TEST_NAME##_UnitTest; \
00097   \
00098         void TEST_GROUP##_##TEST_NAME##_UnitTest::runUnitTestImpl( \
00099     Teuchos::FancyOStream &out, bool &success ) const \
00100 
00101 
00160 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE) \
00161   template<class TYPE> \
00162   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00163         { \
00164   public: \
00165     TEST_GROUP##_##TEST_NAME##_UnitTest(const std::string& typeName) \
00166       : Teuchos::UnitTestBase( std::string(#TEST_GROUP)+"_"+typeName, #TEST_NAME ) \
00167     {} \
00168     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00169     virtual std::string unitTestFile() const { return __FILE__; } \
00170     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00171   }; \
00172   \
00173   template<class TYPE> \
00174         void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>::runUnitTestImpl( \
00175     Teuchos::FancyOStream &out, bool &success ) const \
00176 
00177 
00187 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, TYPE) \
00188   \
00189   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE>; \
00190   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE> \
00191   instance_##TEST_GROUP##_##TYPE##_##TEST_NAME##_UnitTest(#TYPE);
00192 
00193 
00194 #ifdef HAVE_TEUCHOS_FLOAT
00195 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)\
00196     TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, float)
00197 #else
00198 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME)
00199 #endif
00200 
00201 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)\
00202   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, double)
00203 
00204 #if defined(HAVE_TEUCHOS_COMPLEX) && defined(HAVE_TEUCHOS_FLOAT)
00205 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)\
00206      typedef std::complex<float> ComplexFloat; \
00207      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexFloat)
00208 #else
00209 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME)
00210 #endif
00211 
00212 #ifdef HAVE_TEUCHOS_COMPLEX
00213 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)\
00214      typedef std::complex<double> ComplexDouble; \
00215      TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT(TEST_GROUP, TEST_NAME, ComplexDouble)
00216 #else
00217 #  define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00218 #endif
00219 
00220 
00226 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_REAL_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00227   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00228   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME)
00229 
00230 
00235 #define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES(TEST_GROUP, TEST_NAME)\
00236   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_FLOAT(TEST_GROUP, TEST_NAME) \
00237   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_DOUBLE(TEST_GROUP, TEST_NAME) \
00238   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME) \
00239   TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME)
00240 
00241 
00302 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00303   template<class TYPE1, class TYPE2> \
00304   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00305         { \
00306   public: \
00307     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00308       const std::string& type1Name, \
00309       const std::string& type2Name \
00310        ) \
00311       :Teuchos::UnitTestBase( \
00312          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name, #TEST_NAME ) \
00313     {} \
00314     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00315     virtual std::string unitTestFile() const { return __FILE__; } \
00316     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00317   }; \
00318   \
00319   template<class TYPE1, class TYPE2> \
00320         void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2>::runUnitTestImpl( \
00321     Teuchos::FancyOStream &out, bool &success ) const \
00322 
00323 
00333 #define TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2) \
00334   \
00335   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 >; \
00336   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2 > \
00337   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2);
00338 
00339 
00344 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00345   template<class TYPE1, class TYPE2, class TYPE3> \
00346   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00347         { \
00348   public: \
00349     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00350       const std::string& type1Name, \
00351       const std::string& type2Name, \
00352       const std::string& type3Name \
00353        ) \
00354       :Teuchos::UnitTestBase( \
00355          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name, #TEST_NAME ) \
00356     {} \
00357     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00358     virtual std::string unitTestFile() const { return __FILE__; } \
00359     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00360   }; \
00361   \
00362   template<class TYPE1, class TYPE2, class TYPE3> \
00363         void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3>::runUnitTestImpl( \
00364     Teuchos::FancyOStream &out, bool &success ) const \
00365 
00366 
00371 #define TEUCHOS_UNIT_TEST_TEMPLATE_3_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3) \
00372   \
00373   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 >; \
00374   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3 > \
00375   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3);
00376 
00377 
00382 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00383   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00384   class TEST_GROUP##_##TEST_NAME##_UnitTest : public Teuchos::UnitTestBase \
00385         { \
00386   public: \
00387     TEST_GROUP##_##TEST_NAME##_UnitTest( \
00388       const std::string& type1Name, \
00389       const std::string& type2Name, \
00390       const std::string& type3Name, \
00391       const std::string& type4Name \
00392        ) \
00393       :Teuchos::UnitTestBase( \
00394          std::string(#TEST_GROUP)+"_"+type1Name+"_"+type2Name+"_"+type3Name+"_"+type4Name, #TEST_NAME ) \
00395     {} \
00396     void runUnitTestImpl( Teuchos::FancyOStream &out, bool &success ) const; \
00397     virtual std::string unitTestFile() const { return __FILE__; } \
00398     virtual long int unitTestFileLineNumber() const { return __LINE__; } \
00399   }; \
00400   \
00401   template<class TYPE1, class TYPE2, class TYPE3, class TYPE4> \
00402         void TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1,TYPE2,TYPE3,TYPE4>::runUnitTestImpl( \
00403     Teuchos::FancyOStream &out, bool &success ) const \
00404 
00405 
00410 #define TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(TEST_GROUP, TEST_NAME, TYPE1, TYPE2, TYPE3, TYPE4) \
00411   \
00412   template class TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 >; \
00413   TEST_GROUP##_##TEST_NAME##_UnitTest<TYPE1, TYPE2, TYPE3, TYPE4 > \
00414   instance_##TEST_GROUP##_##TYPE1##_##TYPE2##_##TYPE3##_##TYPE4##_##TEST_NAME##_UnitTest(#TYPE1,#TYPE2,#TYPE3,#TYPE4);
00415 
00416 
00417 #endif  // TEUCHOS_UNIT_TEST_HELPERS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines