blob: 148497798e2f7702f06a7306dfb49e554c961dcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
#include <cppunit/Portability.h>
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( push )
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
#endif
#include <cppunit/extensions/TestFactory.h>
#include <map>
#include <string>
namespace CppUnit {
class TestSuite;
#if CPPUNIT_NEED_DLL_DECL
template class CPPUNIT_API std::map<std::string, TestFactory *>;
#endif
/** This class implements a registry for test factory.
*
* Note that the registry assume lifetime control for any registered test.
*/
class CPPUNIT_API TestFactoryRegistry : public TestFactory
{
public:
/** Constructs the registry with the specified name.
* \param name Name of the registry.
*/
TestFactoryRegistry( std::string name = "All Tests" );
/// Destructor.
virtual ~TestFactoryRegistry();
/** Makes a suite containing all the registered test.
* \return A new suite containing all the registered test.
*/
virtual Test *makeTest();
/** Returns the registry.
* \return Registry.
*/
static TestFactoryRegistry &getRegistry();
/** Returns a named registry.
* \param name Name of the registry to return.
* \return Registry. If the registry does not exist, it is created.
*/
static TestFactoryRegistry &getRegistry( const std::string &name );
/** Adds the registered test to the specified suite.
* \param suite Suite the test are added to.
*/
void addTestToSuite( TestSuite *suite );
/** Registers a test factory with the specified name.
* \param name Name associated to the factory.
* \param factory Factory to register.
*/
void registerFactory( const std::string &name,
TestFactory *factory );
/** Registers a test factory using its class name.
* \param factory Factory to register.
*/
void registerFactory( TestFactory *factory );
private:
TestFactoryRegistry( const TestFactoryRegistry © );
void operator =( const TestFactoryRegistry © );
private:
typedef std::map<std::string, TestFactory *> Factories;
Factories m_factories;
std::string m_name;
};
} // namespace CppUnit
#if CPPUNIT_NEED_DLL_DECL
#pragma warning( pop )
#endif
#endif // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
|