Esempio n. 1
0
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_));
	}
}
Esempio n. 2
0
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();
}
Esempio n. 3
0
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 );
}
Esempio n. 4
0
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;
    }
}
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);
    }
}
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;
}
Esempio n. 7
0
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;

}
Esempio n. 8
0
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;

}
Esempio n. 9
0
    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_);
    }
Esempio n. 10
0
    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_);
    }