[Cppunit-cvs] cppunit2/include/cpput registry.h, 1.8, 1.9 testcase.h, 1.14, 1.15
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2007-08-15 11:21:00
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8069/include/cpput Modified Files: registry.h testcase.h Log Message: Added support for light test fixture (a la CppUnitLite). See lightfixture.h and example/light_fixture. Added support for direct declaration and registration of test in plain C function. See testfunction.h and example/test_function. Index: testcase.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testcase.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** testcase.h 12 Nov 2005 20:55:46 -0000 1.14 --- testcase.h 15 Aug 2007 11:20:57 -0000 1.15 *************** *** 75,78 **** --- 75,85 ---- * \ingroup group_testcases */ + TestPtr CPPUT_API makeTestCase( void (*run)(), + const std::string &name ); + + + /*! \brief Creates a TestCase with the specified name and run functor. + * \ingroup group_testcases + */ TestPtr CPPUT_API makeTestCase( const CppTL::Functor0 &run, const std::string &name ); Index: registry.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/registry.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** registry.h 11 Nov 2005 23:23:48 -0000 1.8 --- registry.h 15 Aug 2007 11:20:57 -0000 1.9 *************** *** 21,25 **** /*! \ingroup group_testregistry ! */ class CPPUT_API Registry { --- 21,28 ---- /*! \ingroup group_testregistry ! * Static registry for all tests. ! * Any suite or test added to the registry by a dynamic library that contains test should ! * be removed using remove(). Helper macros take carre of this. ! */ class CPPUT_API Registry { *************** *** 33,36 **** --- 36,40 ---- void addChild( const std::string &parentSuiteName, const std::string &childSuiteName ); + void addChildToDefault( const std::string &childSuiteName ); bool removeChild( const std::string &parentSuiteName, *************** *** 182,185 **** --- 186,196 ---- { public: + explicit SuiteRelationshipRegisterer( const std::string &childSuiteName ) + : childSuiteName_( childSuiteName ) + , parentSuiteName_( Registry::defaultParentSuiteName() ) + { + Registry::instance().addChildToDefault( childSuiteName ); + } + SuiteRelationshipRegisterer( const std::string &parentSuiteName, const std::string &childSuiteName ) *************** *** 205,209 **** */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ ! static CppUT::SuiteRelationshipRegisterer \ CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ --- 216,220 ---- */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ ! static ::CppUT::SuiteRelationshipRegisterer \ CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ *************** *** 214,221 **** */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP_TO_DEFAULT( childSuiteName ) \ ! CPPUT_REGISTER_SUITE_RELATIONSHIP( \ ! CppUT::Registry::instance().getDefaultName(), \ ! childSuiteName ) } // namespace CppUT --- 225,285 ---- */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP_TO_DEFAULT( childSuiteName ) \ ! static ::CppUT::SuiteRelationshipRegisterer \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ ! childSuiteName ) ! ! ! // Plain C function tests ! ! /*! \ingroup group_testregistry ! * \brief Helper object used to statically register a TestFactory. ! */ ! class TestFactoryRegisterer ! { ! public: ! typedef TestPtr (*FactoryFn)(); ! ! TestFactoryRegisterer( FactoryFn testFactory ) ! { ! testFactoryId_ = Registry::instance().addToDefault( CppTL::cfn0r<TestPtr>(testFactory) ); ! } + TestFactoryRegisterer( TestFactory testFactory ) + { + testFactoryId_ = Registry::instance().addToDefault( testFactory ); + } + + TestFactoryRegisterer( TestFactory testFactory, const std::string &parentSuiteName ) + { + testFactoryId_ = Registry::instance().add( parentSuiteName, testFactory ); + } + + TestFactoryRegisterer( FactoryFn testFactory, const std::string &parentSuiteName ) + { + testFactoryId_ = Registry::instance().add( parentSuiteName, CppTL::cfn0r<TestPtr>(testFactory) ); + } + + ~TestFactoryRegisterer() + { + Registry::instance().remove( testFactoryId_ ); + } + + private: + TestFactoryId testFactoryId_; + }; + + /*! \ingroup group_testregistry + * \brief Register the specified TestFactory in the default Registry suite. + */ + #define CPPUT_REGISTER_TESTFACTORY_TO_DEFAULT( testFactory ) \ + static ::CppUT::TestFactoryRegisterer \ + CPPTL_MAKE_UNIQUE_NAME(cpputTestFactoryRegisterer)( testFactory ) + + /*! \ingroup group_testregistry + * \brief Register the specified TestFactory in the specified Registry suite. + */ + #define CPPUT_REGISTER_TESTFACTORY_IN( testFactory, parentSuiteName ) \ + static ::CppUT::TestFactoryRegisterer \ + CPPTL_MAKE_UNIQUE_NAME(cpputTestFactoryRegisterer)( testFactory, parentSuiteName ) } // namespace CppUT |