本文整理汇总了C++中Suite::run方法的典型用法代码示例。如果您正苦于以下问题:C++ Suite::run方法的具体用法?C++ Suite::run怎么用?C++ Suite::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Suite
的用法示例。
在下文中一共展示了Suite::run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int Suite::run( vector<string> suites ){
for ( unsigned int i = 0; i < suites.size(); i++ ) {
if ( _suites->find( suites[i] ) == _suites->end() ) {
cout << "invalid test [" << suites[i] << "], use --list to see valid names" << endl;
return -1;
}
}
list<string> torun(suites.begin(), suites.end());
if ( torun.size() == 0 )
for ( map<string,Suite*>::iterator i=_suites->begin() ; i!=_suites->end(); i++ )
torun.push_back( i->first );
list<Result*> results;
for ( list<string>::iterator i=torun.begin(); i!=torun.end(); i++ ){
string name = *i;
Suite * s = (*_suites)[name];
assert( s );
log() << "going to run suite: " << name << endl;
results.push_back( s->run() );
}
Logstream::get().flush();
cout << "**************************************************" << endl;
cout << "**************************************************" << endl;
cout << "**************************************************" << endl;
int rc = 0;
int tests = 0;
int fails = 0;
int asserts = 0;
for ( list<Result*>::iterator i=results.begin(); i!=results.end(); i++ ){
Result * r = *i;
cout << r->toString();
if ( abs( r->rc() ) > abs( rc ) )
rc = r->rc();
tests += r->_tests;
fails += r->_fails;
asserts += r->_asserts;
}
Result totals ("TOTALS");
totals._tests = tests;
totals._fails = fails;
totals._asserts = asserts;
cout << totals.toString(); // includes endl
return rc;
}
示例2: UniTest
void UniTest()
{
Suite ts;
AddTest(ts);
std::auto_ptr<Output> output(new XmlOutput);
ts.run(*output, true);
Test::XmlOutput* const xml_output = dynamic_cast<XmlOutput*>(output.get());
if (xml_output)
{
std::ofstream fout("./test_pellets.xml");
xml_output->generate(fout, true, "zpublic");
}
}
示例3: run
int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) {
if (_allSuites().empty()) {
log() << "error: no suites registered.";
return EXIT_FAILURE;
}
for ( unsigned int i = 0; i < suites.size(); i++ ) {
if ( _allSuites().count( suites[i] ) == 0 ) {
log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl;
return EXIT_FAILURE;
}
}
std::vector<std::string> torun(suites);
if ( torun.empty() ) {
for ( SuiteMap::const_iterator i = _allSuites().begin();
i !=_allSuites().end(); ++i ) {
torun.push_back( i->first );
}
}
std::vector<Result*> results;
for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) {
std::string name = *i;
Suite* s = _allSuites()[name];
fassert( 16145, s );
log() << "going to run suite: " << name << std::endl;
results.push_back( s->run( filter, runsPerTest ) );
}
log() << "**************************************************" << std::endl;
int rc = 0;
int tests = 0;
int asserts = 0;
int millis = 0;
Result totals ("TOTALS");
std::vector<std::string> failedSuites;
for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) {
Result* r = *i;
log() << r->toString();
if ( abs( r->rc() ) > abs( rc ) )
rc = r->rc();
tests += r->_tests;
if ( !r->_fails.empty() ) {
failedSuites.push_back(r->toString());
for ( std::vector<std::string>::const_iterator j=r->_fails.begin();
j!=r->_fails.end(); j++ ) {
const std::string& s = (*j);
totals._fails.push_back(r->_name + "/" + s);
}
}
asserts += r->_asserts;
millis += r->_millis;
}
totals._tests = tests;
totals._asserts = asserts;
totals._millis = millis;
log() << totals.toString(); // includes endl
// summary
if ( !totals._fails.empty() ) {
log() << "Failing tests:" << std::endl;
for ( std::vector<std::string>::const_iterator i=totals._fails.begin();
i!=totals._fails.end(); i++ ) {
const std::string& s = (*i);
log() << "\t " << s << " Failed";
}
log() << "FAILURE - " << totals._fails.size() << " tests in "
<< failedSuites.size() << " suites failed";
}
else {
log() << "SUCCESS - All tests in all suites passed";
}
return rc;
}
示例4: run
int Suite::run( int argc , char ** argv ){
list<string> torun;
for ( int i=1; i<argc; i++ ){
string s = argv[i];
if ( s == "-list" ){
for ( map<string,Suite*>::iterator i=_suites->begin() ; i!=_suites->end(); i++ )
cout << i->first << endl;
return 0;
}
if ( s == "-debug" ){
logLevel = 1;
continue;
}
torun.push_back( s );
if ( _suites->find( s ) == _suites->end() ){
cout << "invalid test [" << s << "] use -list to see valid names" << endl;
return -1;
}
}
if ( torun.size() == 0 )
for ( map<string,Suite*>::iterator i=_suites->begin() ; i!=_suites->end(); i++ )
torun.push_back( i->first );
list<Result*> results;
for ( list<string>::iterator i=torun.begin(); i!=torun.end(); i++ ){
string name = *i;
Suite * s = (*_suites)[name];
assert( s );
log() << "going to run suite: " << name << endl;
results.push_back( s->run() );
}
cout << "**************************************************" << endl;
cout << "**************************************************" << endl;
cout << "**************************************************" << endl;
int rc = 0;
int tests = 0;
int fails = 0;
int asserts = 0;
for ( list<Result*>::iterator i=results.begin(); i!=results.end(); i++ ){
Result * r = *i;
cout << r->toString();
if ( abs( r->rc() ) > abs( rc ) )
rc = r->rc();
tests += r->_tests;
fails += r->_fails;
asserts += r->_asserts;
}
cout << "TOTALS tests:" << tests << " fails: " << fails << " asserts calls: " << asserts << endl;
return rc;
}
示例5: run
int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) {
if (_allSuites().empty()) {
log() << "error: no suites registered.";
return EXIT_FAILURE;
}
for ( unsigned int i = 0; i < suites.size(); i++ ) {
if ( _allSuites().count( suites[i] ) == 0 ) {
log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl;
return EXIT_FAILURE;
}
}
std::vector<std::string> torun(suites);
if ( torun.empty() ) {
for ( SuiteMap::const_iterator i = _allSuites().begin();
i !=_allSuites().end(); ++i ) {
torun.push_back( i->first );
}
}
std::vector<Result*> results;
for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) {
std::string name = *i;
Suite* s = _allSuites()[name];
fassert( 16145, s );
log() << "going to run suite: " << name << std::endl;
results.push_back( s->run( filter, runsPerTest ) );
}
log() << "**************************************************" << std::endl;
int rc = 0;
int tests = 0;
int fails = 0;
int asserts = 0;
for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) {
Result* r = *i;
log() << r->toString();
if ( abs( r->rc() ) > abs( rc ) )
rc = r->rc();
tests += r->_tests;
fails += r->_fails;
asserts += r->_asserts;
}
Result totals ("TOTALS");
totals._tests = tests;
totals._fails = fails;
totals._asserts = asserts;
log() << totals.toString(); // includes endl
return rc;
}