CppUnit project page FAQ CppUnit home page

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
include / cppunit / extensions

AutoRegisterSuite.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
00002 #define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
00003 
00004 #include <cppunit/extensions/TestSuiteFactory.h>
00005 #include <cppunit/extensions/TestFactoryRegistry.h>
00006 #include <string>
00007 
00008 CPPUNIT_NS_BEGIN
00009 
00010 
00027 template<class TestCaseType>
00028 class AutoRegisterSuite
00029 {
00030 public:
00033 AutoRegisterSuite()
00034 : m_registry( &TestFactoryRegistry::getRegistry() )
00035 {
00036 m_registry->registerFactory( &m_factory );
00037 }
00038 
00042 AutoRegisterSuite( const std::string &name )
00043 : m_registry( &TestFactoryRegistry::getRegistry( name ) )
00044 {
00045 m_registry->registerFactory( &m_factory );
00046 }
00047 
00048 ~AutoRegisterSuite()
00049 {
00050 if ( TestFactoryRegistry::isValid() )
00051 m_registry->unregisterFactory( &m_factory );
00052 }
00053 
00054 private:
00055 TestFactoryRegistry *m_registry;
00056 TestSuiteFactory<TestCaseType> m_factory;
00057 };
00058 
00059 
00065 class AutoRegisterRegistry
00066 {
00067 public:
00068 AutoRegisterRegistry( const std::string &which,
00069 const std::string &to )
00070 {
00071 TestFactoryRegistry::getRegistry( to ).addRegistry( which );
00072 }
00073 
00074 AutoRegisterRegistry( const std::string &which )
00075 {
00076 TestFactoryRegistry::getRegistry().addRegistry( which );
00077 }
00078 };
00079 
00080 
00081 CPPUNIT_NS_END
00082 
00083 #endif // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H

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

AltStyle によって変換されたページ (->オリジナル) /