CppUnit - The Unit Testing Library

CppUnit project page | FAQ

TestFactoryRegistry.h
Go to the documentation of this file.
1#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
2#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
3
4#include <cppunit/Portability.h>
5
6#if CPPUNIT_NEED_DLL_DECL
7#pragma warning( push )
8#pragma warning( disable: 4251) // X needs to have dll-interface to be used by clients of class Z
9#endif
10
11#include <set>
12#include <cppunit/extensions/TestFactory.h>
13#include <string>
14
15 CPPUNIT_NS_BEGIN
16
17
18class TestSuite;
19
75 class CPPUNIT_API TestFactoryRegistry : public TestFactory
76{
77public:
82 TestFactoryRegistry( std::string name );
83
85 virtual ~TestFactoryRegistry();
86
91 virtual Test *makeTest();
92
102 static TestFactoryRegistry &getRegistry( const std::string &name = "All Tests" );
103
107 void addTestToSuite( TestSuite *suite );
108
113 void registerFactory( TestFactory *factory );
114
121 void unregisterFactory( TestFactory *factory );
122
133 void addRegistry( const std::string &name );
134
148 static bool isValid();
149
155 void registerFactory( const std::string &name,
156 TestFactory *factory );
157
158private:
159 TestFactoryRegistry( const TestFactoryRegistry &copy );
160 void operator =( const TestFactoryRegistry &copy );
161
162private:
163 typedef std::set<TestFactory *, std::less<TestFactory*> > Factories;
164 Factories m_factories;
165
166 std::string m_name;
167};
168
169
170 CPPUNIT_NS_END
171
172#if CPPUNIT_NEED_DLL_DECL
173#pragma warning( pop )
174#endif
175
176
177#endif // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
CPPUNIT_API
#define CPPUNIT_API
Definition CppUnitApi.h:27
Portability.h
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition Portability.h:106
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition Portability.h:105
TestFactory.h
TestFactory
Abstract Test factory.
Definition TestFactory.h:14
TestFactory::makeTest
virtual Test * makeTest()=0
TestFactoryRegistry::TestFactoryRegistry
TestFactoryRegistry(const TestFactoryRegistry &copy)
TestFactoryRegistry::addTestToSuite
void addTestToSuite(TestSuite *suite)
Adds the registered tests to the specified suite.
Definition TestFactoryRegistry.cpp:144
TestFactoryRegistry::isValid
static bool isValid()
Definition TestFactoryRegistry.cpp:157
TestFactoryRegistry::registerFactory
void registerFactory(TestFactory *factory)
Adds the specified TestFactory to the registry.
Definition TestFactoryRegistry.cpp:114
TestFactoryRegistry::TestFactoryRegistry
TestFactoryRegistry(std::string name)
Constructs the registry with the specified name.
Definition TestFactoryRegistry.cpp:86
TestFactoryRegistry::m_factories
Factories m_factories
Definition TestFactoryRegistry.h:164
TestFactoryRegistry::Factories
std::set< TestFactory *, std::less< TestFactory * > > Factories
Definition TestFactoryRegistry.h:163
TestFactoryRegistry::addRegistry
void addRegistry(const std::string &name)
Definition TestFactoryRegistry.cpp:128
TestFactoryRegistry::getRegistry
static TestFactoryRegistry & getRegistry(const std::string &name="All Tests")
Returns a named registry.
Definition TestFactoryRegistry.cpp:99
TestFactoryRegistry::m_name
std::string m_name
Definition TestFactoryRegistry.h:166
TestFactoryRegistry::unregisterFactory
void unregisterFactory(TestFactory *factory)
Definition TestFactoryRegistry.cpp:121
Test
Base class for all test objects.
Definition Test.h:26
TestSuite
A Composite of Tests.
Definition TestSuite.h:41

| Send comments to: CppUnit Developers