本文整理汇总了C++中TestResult::failed方法的典型用法代码示例。如果您正苦于以下问题:C++ TestResult::failed方法的具体用法?C++ TestResult::failed怎么用?C++ TestResult::failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestResult
的用法示例。
在下文中一共展示了TestResult::failed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runAllTest
bool Runner::runAllTest(bool printSummary) const {
unsigned int count = testCount();
std::deque<TestResult> failures;
for (unsigned int index = 0; index < count; ++index) {
TestResult result;
runTestAt(index, result);
if (result.failed()) {
failures.push_back(result);
}
}
if (failures.empty()) {
if (printSummary) {
printf("All %d tests passed\n", count);
}
return true;
} else {
for (unsigned int index = 0; index < failures.size(); ++index) {
TestResult& result = failures[index];
result.printFailure(count > 1);
}
if (printSummary) {
unsigned int failedCount = static_cast<unsigned int>(failures.size());
unsigned int passedCount = count - failedCount;
printf("%d/%d tests passed (%d failure(s))\n",
passedCount,
count,
failedCount);
}
return false;
}
}
示例2: printf
void
Runner::runTestAt( unsigned int index, TestResult &result ) const
{
TestCase *test = tests_[index]();
result.setTestName( test->testName() );
printf( "Testing %s: ", test->testName() );
fflush( stdout );
#if JSON_USE_EXCEPTION
try
{
#endif // if JSON_USE_EXCEPTION
test->run( result );
#if JSON_USE_EXCEPTION
}
catch ( const std::exception &e )
{
result.addFailure( __FILE__, __LINE__,
"Unexpected exception caugth:" ) << e.what();
}
#endif // if JSON_USE_EXCEPTION
delete test;
const char *status = result.failed() ? "FAILED"
: "OK";
printf( "%s\n", status );
fflush( stdout );
}