1 #ifndef TUT_RUNNER_H_GUARD
2 #define TUT_RUNNER_H_GUARD
7 #include "tut_exception.hpp"
23 virtual void rewind() = 0;
95 virtual bool all_ok()
const
108 typedef std::set<callback*> callbacks;
136 throw tut_error(
"group shall be non-null");
139 if (groups_.find(name) != groups_.end())
141 std::string msg(
"attempt to add already existent group " + name);
145 groups_.insert( std::make_pair(name, gr) );
166 callbacks_.insert(cb);
176 callbacks_.erase(cb);
212 for(const_iterator i = groups_.begin(); i != groups_.end(); ++i)
214 ret.push_back(i->first);
226 const_iterator i = groups_.begin();
227 const_iterator e = groups_.end();
230 cb_group_started_(i->first);
231 run_all_tests_in_group_(i);
232 cb_group_completed_(i->first);
248 const_iterator i = groups_.find(group_name);
249 if (i == groups_.end())
255 cb_group_started_(group_name);
256 run_all_tests_in_group_(i);
257 cb_group_completed_(group_name);
272 const_iterator i = groups_.find(group_name);
273 if (i == groups_.end())
279 cb_group_started_(group_name);
281 bool t = i->second->run_test(n, tr);
283 if(t && tr.result != test_result::dummy)
285 cb_test_completed_(tr);
288 cb_group_completed_(group_name);
296 typedef std::map<std::string, group_base*> groups;
297 typedef groups::iterator iterator;
298 typedef groups::const_iterator const_iterator;
301 callbacks callbacks_;
306 void cb_run_started_()
const
308 for(callbacks::const_iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
314 void cb_run_completed_()
const
316 for(callbacks::const_iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
318 (*i)->run_completed();
322 void cb_group_started_(
const std::string &group_name)
const
324 for(callbacks::const_iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
326 (*i)->group_started(group_name);
330 void cb_group_completed_(
const std::string &group_name)
const
332 for(callbacks::const_iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
334 (*i)->group_completed(group_name);
338 void cb_test_completed_(
const test_result &tr)
const
340 for(callbacks::const_iterator i = callbacks_.begin(); i != callbacks_.end(); ++i)
342 (*i)->test_completed(tr);
346 void run_all_tests_in_group_(const_iterator i)
const
351 while(i->second->run_next(tr))
353 if(tr.result != test_result::dummy)
355 cb_test_completed_(tr);
358 if (tr.result == test_result::ex_ctor)
387 #endif // TUT_RUNNER_H_GUARD
Definition: tut_exception.hpp:13
void run_tests(const std::string &group_name) const
Definition: tut_runner.hpp:244
Definition: tut_runner.hpp:113
Definition: tut_exception.hpp:48
virtual void run_completed()
Definition: tut_runner.hpp:91
bool run_test(const std::string &group_name, int n, test_result &tr) const
Definition: tut_runner.hpp:268
void clear_callbacks()
Definition: tut_runner.hpp:182
void set_callbacks(const callbacks &cb)
Definition: tut_runner.hpp:200
virtual void group_completed(const std::string &name)
Definition: tut_runner.hpp:83
virtual void test_completed(const test_result &tr)
Definition: tut_runner.hpp:74
void set_callback(callback *cb)
Definition: tut_runner.hpp:152
std::vector< std::string > groupnames
Definition: tut_runner.hpp:107
Definition: tut_runner.hpp:372
void register_group(const std::string &name, group_base *gr)
Definition: tut_runner.hpp:132
Definition: tut_runner.hpp:16
Definition: tut_restartable.hpp:194
void run_tests() const
Definition: tut_runner.hpp:222
void insert_callback(callback *cb)
Definition: tut_runner.hpp:162
callback()
Definition: tut_runner.hpp:43
virtual void group_started(const std::string &name)
Definition: tut_runner.hpp:65
void erase_callback(callback *cb)
Definition: tut_runner.hpp:174
const groupnames list_groups() const
Definition: tut_runner.hpp:209
Definition: tut_result.hpp:69
const callbacks & get_callbacks() const
Definition: tut_runner.hpp:191
test_runner()
Definition: tut_runner.hpp:121
virtual ~callback()
Definition: tut_runner.hpp:50
Definition: tut_runner.hpp:38
virtual void run_started()
Definition: tut_runner.hpp:57