blob: 3f390f6d87855a0adeabd9a342ee4b50251c20b3 (
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
|
#if _MSC_VER > 1000 // VC++
#pragma once
#pragma warning( disable : 4786 ) // disable warning debug symbol > 255...
#endif // _MSC_VER > 1000
#include <utility>
#include "cppunit/TestSuite.h"
#include "cppunit/extensions/TestFactoryRegistry.h"
#include "cppunit/extensions/TestSuiteBuilder.h"
#ifdef USE_TYPEINFO
#include "../TypeInfoHelper.h"
#endif // USE_TYPEINFO
namespace CppUnit {
TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
m_name( name )
{
}
TestFactoryRegistry::~TestFactoryRegistry()
{
}
TestFactoryRegistry &
TestFactoryRegistry::getRegistry()
{
static TestFactoryRegistry registry;
return registry;
}
TestFactoryRegistry &
TestFactoryRegistry::getRegistry( const std::string &name )
{
static NamedRegistries registries;
TestFactoryRegistry*& registryPointer = registries[ name ];
if (NULL == registryPointer) {
registryPointer = new TestFactoryRegistry( name );
}
return *registryPointer;
}
void
TestFactoryRegistry::registerFactory( const std::string &name,
AbstractTestFactory *factory )
{
m_factories[name] = factory;
}
#ifdef USE_TYPEINFO
void
TestFactoryRegistry::registerFactory( AbstractTestFactory *factory )
{
std::string name = TypeInfoHelper::getClassName( typeid( *factory ) );
registerFactory( name, factory );
}
#endif // USE_TYPEINFO
Test *
TestFactoryRegistry::makeTest()
{
TestSuite *suite = new TestSuite( "All Tests" );
addTestToSuite( suite );
return suite;
}
void
TestFactoryRegistry::addTestToSuite( TestSuite *suite )
{
for ( Factories::iterator it = m_factories.begin();
it != m_factories.end();
++it )
{
AbstractTestFactory *factory = (*it).second;
suite->addTest( factory->makeTest() );
}
}
} // namespace CppUnit
|