本文整理汇总了C++中TestResult::addFailure方法的典型用法代码示例。如果您正苦于以下问题:C++ TestResult::addFailure方法的具体用法?C++ TestResult::addFailure怎么用?C++ TestResult::addFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestResult
的用法示例。
在下文中一共展示了TestResult::addFailure方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void Test::run(TestResult &result) {
try {
runInternal();
} catch (TestFailException *e) {
result.addFailure(Failure(*e, name_));
} catch (std::exception &e) {
std::stringstream ss;
ss << "unexpected exception " << e.what();
result.addFailure(Failure(ss.str(), name_));
} catch (...) {
result.addFailure(Failure("unknown exception", name_));
}
}
示例2: run
void Test::run (TestResult& result)
{
try {
setup();
runTest (result);
} catch (std::exception e) {
result.addFailure (Failure (e.what(), name, "", 0));
} catch (...) {
result.addFailure (Failure ("Unhandled exception", name, "", 0));
}
teardown();
result.testWasRun();
}
示例3: 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 );
}
示例4: check_equal_compare
void check_equal_compare(const char* const expected, const char* const actual, TestResult& result, char* file, int line)
{
if (strcmp((expected), (actual)) != 0) {
std::ostringstream message;
message << "expected '" << (expected) << "' but was '" << (actual) << "'";
result.addFailure (Failure (message.str(), file, line));
return;
}
}
示例5: failure
void IEEE754ExceptionsPlugin::ieee754Check(UtestShell& test, TestResult& result, int flag, const char* text)
{
result.countCheck();
if(inexactDisabled_) CHECK(!feclearexcept(FE_INEXACT));
if(fetestexcept(flag)) {
CHECK(!feclearexcept(FE_ALL_EXCEPT));
CheckFailure failure(&test, __FILE__, __LINE__, "IEEE754_CHECK_CLEAR", text);
result.addFailure(failure);
}
}
示例6: postTestAction
void MemoryLeakWarningPlugin::postTestAction(UtestShell& test, TestResult& result)
{
memLeakDetector_->stopChecking();
int leaks = memLeakDetector_->totalMemoryLeaks(mem_leak_period_checking);
if (!ignoreAllWarnings_ && expectedLeaks_ != leaks && failureCount_ == result.getFailureCount()) {
TestFailure f(&test, memLeakDetector_->report(mem_leak_period_checking));
result.addFailure(f);
}
memLeakDetector_->markCheckingPeriodLeaksAsNonCheckingPeriod();
ignoreAllWarnings_ = false;
expectedLeaks_ = 0;
}
示例7: check
bool Test::check(long expected, long actual, TestResult& result, const SimpleString& fileName, long lineNumber) {
if (expected == actual)
return true;
result.addFailure (
Failure (
name_,
StringFrom (__FILE__),
__LINE__,
StringFrom (expected),
StringFrom (actual)));
return false;
}
示例8: check
bool Test::check(const std::string& expected, const std::string& actual, TestResult& result, const std::string& fileName, long lineNumber)
{
if (expected == actual)
return true;
result.addFailure (
Failure (
name_,
boost::lexical_cast<std::string> (__FILE__),
__LINE__,
expected,
actual));
return false;
}
示例9: runPreviousTest
void runPreviousTest()
{
if (currentTest_ == 0) return;
if (firstTestInGroup_) {
result_.currentGroupStarted(currentTest_);
firstTestInGroup_ = false;
}
result_.currentTestStarted(currentTest_);
millisTime += timeTheTestTakes_;
if (testFailure_) {
result_.addFailure(*testFailure_);
delete testFailure_;
testFailure_ = 0;
}
result_.currentTestEnded(currentTest_);
}
示例10: runPreviousTest
void runPreviousTest()
{
if (currentTest_ == 0) return;
if (firstTestInGroup_) {
result_.currentGroupStarted(currentTest_);
firstTestInGroup_ = false;
}
result_.currentTestStarted(currentTest_);
millisTime += timeTheTestTakes_;
for(unsigned int i = 0; i < numberOfChecksInTest_; i++) {
result_.countCheck();
}
numberOfChecksInTest_ = 0;
if (testFailure_) {
result_.addFailure(*testFailure_);
delete testFailure_;
testFailure_ = 0;
}
result_.currentTestEnded(currentTest_);
}