CppUnit project page
FAQ
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
include
cppunit
extensions
AutoRegisterSuite.h
Go to the documentation of this file.
1
#ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
2
#define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
3
4
#include <
cppunit/extensions/TestSuiteFactory.h
>
5
#include <
cppunit/extensions/TestFactoryRegistry.h
>
6
#include <string>
7
8
CPPUNIT_NS_BEGIN
9
10
27
template
<
class
TestCaseType>
28
class
AutoRegisterSuite
29
{
30
public
:
33
AutoRegisterSuite
()
34
:
m_registry
( &
TestFactoryRegistry
::getRegistry() )
35
{
36
m_registry
->
registerFactory
( &
m_factory
);
37
}
38
42
AutoRegisterSuite
(
const
std::string &name )
43
:
m_registry
( &
TestFactoryRegistry
::getRegistry( name ) )
44
{
45
m_registry
->
registerFactory
( &
m_factory
);
46
}
47
48
~AutoRegisterSuite
()
49
{
50
if
(
TestFactoryRegistry::isValid
() )
51
m_registry
->
unregisterFactory
( &
m_factory
);
52
}
53
54
private
:
55
TestFactoryRegistry
*
m_registry
;
56
TestSuiteFactory<TestCaseType>
m_factory
;
57
};
58
59
65
class
AutoRegisterRegistry
66
{
67
public
:
68
AutoRegisterRegistry
(
const
std::string &which,
69
const
std::string &to )
70
{
71
TestFactoryRegistry::getRegistry
( to ).
addRegistry
( which );
72
}
73
74
AutoRegisterRegistry
(
const
std::string &which )
75
{
76
TestFactoryRegistry::getRegistry
().
addRegistry
( which );
77
}
78
};
79
80
81
CPPUNIT_NS_END
82
83
#endif // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
Send comments to:
CppUnit Developers