blob: 5594f3006ec2f1a178a8a62979d8cb899f4b9397 (
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
|
#include "cppunit/TestRegistry.h"
#include "cppunit/Test.h"
//using namespace std;
namespace CppUnit {
std::vector<std::string> s_registry_names;
std::vector<Test*> s_registry_tests;
static TestRegistry* s_registry;
static bool instanciated=false;
TestRegistry&
TestRegistry::getRegistry ()
{
if(!instanciated) {
s_registry=new TestRegistry();
instanciated=true;
}
return *s_registry;
}
void
TestRegistry::addTest(std::string name, Test *test)
{
s_registry_names.push_back (name);
s_registry_tests.push_back (test);
}
const std::vector<std::string>&
TestRegistry::getAllTestNames () const
{
return(s_registry_names);
}
const std::vector<Test*>&
TestRegistry::getAllTests() const
{
return(s_registry_tests);
}
std::vector<Test*>
TestRegistry::getTest (const std::string& testCase) const
{
std::vector<Test*> res;
std::vector<Test*>::iterator test_it;
std::vector<std::string>::iterator name_it;
for (test_it = s_registry_tests.begin (),
name_it = s_registry_names.begin ();
test_it != s_registry_tests.end ();
++test_it, ++name_it) {
if ((*name_it) == testCase) {
res.push_back((*test_it));
break;
}
}
return(res);
}
TestRegistry::~TestRegistry ()
{
for (std::vector<Test*>::iterator it = s_registry_tests.begin ();
it != s_registry_tests.end ();
++it)
delete *it;
}
TestRegistry::TestRegistry ()
{
}
} // namespace CppUnit
|