1
// Copyright 2006 Rutger E.W. van Beusekom.
2
// Distributed under the Boost Software License, Version 1.0. (See
3
// accompanying file LICENSE_1_0.txt or copy at
4
// http://www.boost.org/LICENSE_1_0.txt)
13
, m_TestResult(0,0,0,"")
16
Factory& Factory::Instance()
18
static Factory singleton;
21
const std::vector<std::string>& Factory::Names()
23
static std::vector<std::string> names;
26
std::vector<Create_t>& tests = Instance().m_Tests;
27
names.push_back("All");
28
for(size_t i = 0; i < tests.size(); ++i)
30
std::auto_ptr<AbstractTest> test(tests[i]());
31
names.push_back(test->name());
36
const TestResult& Factory::Result()
40
void Factory::Register(Create_t create)
42
m_Tests.push_back(create);
44
void Factory::Run(const std::string& name)
49
std::vector<Create_t>& tests = Instance().m_Tests;
55
for(size_t i = 0; i < tests.size(); ++i)
59
std::auto_ptr<AbstractTest> test(tests[i]());
60
if(test->name() == name or "All" == name)
62
total += test->TestFunctions().empty() ? 1 : 0;
63
total += test->TestFunctions().size();
69
m_TestResult = TestResult(total, success, fail, message);
71
bool show_progress = false;
73
for(size_t i = 0; i < tests.size() && !m_Stop; ++i)
79
std::auto_ptr<AbstractTest> test(tests[i]());
82
if(test->name() == name or "All" == name)
84
if(!test->TestFunctions().empty())
86
test->TestFunctions()[j](*test);
90
std::cout << "[OK]\n" << std::endl;
94
show_progress = false;
97
catch(const std::exception& e)
99
message.append(test->name()).append(" [FAIL] ");
100
message.append(e.what()).append("\n\n");
102
std::cout << "[FAIL] " << e.what() << '\n' << std::endl;
107
message.append(test->name()).append(" [FAIL] ");
108
message.append(" unknown exception\n\n");
110
std::cout << "[FAIL] unknown exception\n" << std::endl;
114
m_TestResult = TestResult(total, success, fail, message);
116
sz = test->TestFunctions().size();
119
while(j < sz && !m_Stop);
123
std::cout << "\n[PROGRESS] tested(" << success + fail << '/' << total
124
<< ") succeeded(" << success << '/' << total
125
<< ") failed(" << fail << '/' << total << ")\n" << std::endl;
136
bool Factory::Stopped()
138
return m_Stop and m_Stopped;