23 #ifndef KDAB_NO_UNIT_TESTS 34 KDAB::UnitTest::TestRegistry::TestRegistry()
40 KDAB::UnitTest::TestRegistry::~TestRegistry() {}
53 delete mSelf; mSelf = 0;
58 mTests[group].push_back( tf );
62 unsigned int failed = 0;
63 for ( std::map< std::string, std::vector<const TestFactory*> >::const_iterator g = mTests.begin() ; g != mTests.end() ; ++g ) {
64 std::cerr <<
"===== GROUP \"" << g->first <<
"\" =========" << std::endl;
65 for ( std::vector<const TestFactory*>::const_iterator it = g->second.begin() ; it != g->second.end() ; ++it ) {
66 std::auto_ptr<Test> t( (*it)->create() );
68 std::cerr <<
" === \"" << t->name() <<
"\" ===" << std::endl;
70 std::cerr <<
" Succeeded: " << std::setw( 4 ) << t->succeeded()
71 <<
"; failed: " << std::setw( 4 ) << t->failed() << std::endl;
72 failed += t->failed();
80 assert( group ); assert( *group );
81 unsigned int failed = 0;
82 const std::map< std::string, std::vector<const TestFactory*> >::const_iterator g = mTests.find( group );
83 if ( g == mTests.end() ) {
84 std::cerr <<
"ERROR: No such group \"" << group <<
"\"" << std::endl;
87 std::cerr <<
"===== GROUP \"" << g->first <<
"\" =========" << std::endl;
88 for ( std::vector<const TestFactory*>::const_iterator it = g->second.begin() ; it != g->second.end() ; ++it ) {
89 std::auto_ptr<Test> t( (*it)->create() );
91 std::cerr <<
" === \"" << t->name() <<
"\" ===" << std::endl;
93 std::cerr <<
" Succeeded: " << t->succeeded() <<
"; failed: " << t->failed() << std::endl;
94 failed += t->failed();
106 if ( group && *group )
113 #endif // KDAB_NO_UNIT_TESTS
static TestRegistry * instance()
void registerTestFactory(const TestFactory *tf, const char *group)
unsigned int run(const char *group=0) const
static void deleteInstance()