CppUnit project page CppUnit home page

testfunction.h

Go to the documentation of this file.
00001 #ifndef CPPUT_TESTFUNCTION_H_INCLUDED
00002 # define CPPUT_TESTFUNCTION_H_INCLUDED
00003 
00004 # include "forwards.h"
00005 # include "extendeddata.h"
00006 # include "testcase.h"
00007 # include "registry.h"
00008 
00009 
00010 namespace CppUT 
00011 {
00012    class TestFunctionFactory
00013    {
00014    public:
00015       typedef TestPtr result_type; // Functor return type
00016 
00017       typedef void (*TestFn)();
00018 
00019       TestFunctionFactory( TestFn test, const char *name )
00020          : test_( test )
00021          , name_( name )
00022       {
00023       }
00024 
00025       TestPtr operator()() const
00026       {
00027          return makeTestCase( test_, name_ );
00028       }
00029 
00030       TestFn test_;
00031       const char *name_;
00032    };
00033 } // end namespace CppUT
00034 
00043 #define CPPUT_REGISTER_TEST_FUNCTION( testFunction )                                \
00044    CPPUT_REGISTER_TESTFACTORY_TO_DEFAULT(                                           \
00045    ::CppTL::fn0r( ::CppUT::TestFunctionFactory( &testFunction, #testFunction ) ) )
00046 
00055 #define CPPUT_REGISTER_TEST_FUNCTION_IN( testFunction, parentSuiteName )            \
00056    CPPUT_REGISTER_TESTFACTORY_IN(                                                   \
00057    ::CppTL::fn0r( ::CppUT::TestFunctionFactory( &testFunction, #testFunction )),    \
00058       parentSuiteName )
00059 
00068 #define CPPUT_TEST_FUNCTION( testFunctionName )       \
00069    static void testFunctionName();                    \
00070    CPPUT_REGISTER_TEST_FUNCTION( testFunctionName );  \
00071    static void testFunctionName()
00072 
00081 #define CPPUT_TEST_FUNCTION_IN( testFunctionName, parentSuiteName )       \
00082    static void testFunctionName();                                        \
00083    CPPUT_REGISTER_TEST_FUNCTION_IN( testFunctionName, parentSuiteName );  \
00084    static void testFunctionName()
00085 
00086 /* @todo support for extended test data
00087 CPPUT_REGISTER_TEST_FUNCTION_IN_DEFAULT_WITH_SPECIFICS( 
00088             myTest, 
00089             (timeOut(0.2), 
00090             describe("Always fails")) )
00091 */
00092 
00093 
00094 #endif // CPPUT_TESTFUNCTION_H_INCLUDED

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers