コード例 #1
0
void Test::addTestPartResult(TestPartResult *testPartResult) 
{
  TestPartResult *tmp;
  int type = testPartResult->getType();
 	
  if (testPartResult_ == 0) {
		testPartResult_ = testPartResult;
		testPartResult_->setNext(testPartResult_);
	}
	else {
		tmp = testPartResult_;
		testPartResult_ = testPartResult;
		testPartResult_->setNext(tmp->getNext());
		tmp->setNext(testPartResult_);
	}
	
	if (type == failure) {
	  failuresCount_++;
	}
	else if (type == error) {
		errorsCount_++;
	}  
	else {
		successesCount_++;	  
	}  
}  
コード例 #2
0
// Prints a TestPartResult to an std::string.
std::string PrintTestPartResultToString(const TestPartResult& test_part_result) {
	return (Message()
		<< internal::FormatFileLocation(test_part_result.file_name(),
		test_part_result.line_number())
		<< " " << TestPartResultTypeToString(test_part_result.type())
		<< test_part_result.message()).GetString();
}
コード例 #3
0
TestPartResult* Test::getTestPartResult() const 
{
  TestPartResult *tpr = testPartResult_;
  
  if (tpr != 0) {
  	tpr = tpr->getNext();
  }
  
  return tpr;
}  
コード例 #4
0
void DefaultTestPrinter::printResults( Test *test )
{
	char *indent = "    ";
	TestPartResult *testPR = test->getTestPartResult();
	int size = test->getFailuresCount() + test->getSuccessesCount() + test->getErrorsCount();
	int type;

	for ( int i = 0;i < size;i++ )
	{
		type = testPR->getType();

		if ( type == failure )
		{
			fprintf( output_, "%s%s%s%s%s%ld%s%s\n",
			         indent,
			         "Failure: \"",
			         testPR->getMessage().c_str(),
			         "\" " ,
			         "line ",
			         testPR->getLineNumber(),
			         " in ",
			         testPR->getFileName().c_str() );
		}
		else if ( type == error )
		{
			fprintf( output_, "%s%s%s%s%s%s\n",
			         indent,
			         "Error in ",
			         test->getTestName().c_str(),
			         ": \"",
			         testPR->getMessage().c_str(),
			         "\"" );
		}
		else if ( type == success && showSuccessDetail_ )
		{
			fprintf( output_, "%s%s%s%s%s%ld%s%s\n",
			         indent,
			         "Success: \"",
			         testPR->getMessage().c_str(),
			         "\" " ,
			         "line ",
			         testPR->getLineNumber(),
			         " in ",
			         testPR->getFileName().c_str() );
		}
		testPR = testPR->getNext();
	}
}
コード例 #5
0
	void OnTestPartResult(const TestPartResult& test_part_result)
	{
		if (!m_bDisableAssertOnFailure && test_part_result.failed() && g_bAssertOnFailure.getBool())
		{
			PAUSE_DEBUGGER();
		}
	}
コード例 #6
0
 virtual void ReportTestPartResult(const TestPartResult& result)
 {
     if( result.failed() )
     {
         m_has_new_failure = true;
     }
 }
コード例 #7
0
// Called after an assertion failure.
void SDKUnitTestListener::OnTestPartResult(const TestPartResult& result) {
	// If the test part succeeded, we don't need to do anything.
	if (result.type() == TestPartResult::kSuccess)
		return;

	// Print failure message from the assertion (e.g. expected this and got that).
	std::string res = PrintTestPartResultToString(result);
	PushResult( UTIL_VarArgs( "%s\n", res.c_str() ) );
}
コード例 #8
0
ファイル: TersePrinter.cpp プロジェクト: a-w/astyle
// Called after a failed assertion or a SUCCESS().
// Print the test header for the first error or
// a continuation line for additional errors.
// Then print the failed test summary.
void TersePrinter::OnTestPartResult(const TestPartResult& test_part_result)
{
	if (test_part_result.failed() )
	{
		if (!test_header_printed_)
		{
			// print the message header
			test_header_printed_ = true;
			PrintTestHeader(COLOR_RED);
			// print the file name
			// the following checks for an error in a mock
			if (test_part_result.file_name() || test_part_result.line_number() > 0)
			{
				printf("%s:(%d)\n",
				       test_part_result.file_name(),
				       test_part_result.line_number());
			}
		}
		else
		{
			ColoredPrintf(COLOR_RED, "%s", "[          ]\n");
		}
		// print the failed test summary
		PrintFailedTestSummary(string(test_part_result.summary()));
		fflush(stdout);
	}
}
コード例 #9
0
// Called after a failed assertion or SUCCEED() invocation
void AlternatePrinter::OnTestPartResult(const TestPartResult& test_part_result) {
	fprintf(stdout, "%s in %s:%d\n%s\n\n",
		test_part_result.failed() ? "*** Failure" : "Success", test_part_result.file_name(),
		test_part_result.line_number(), test_part_result.summary());
	fflush(stdout);
}
コード例 #10
0
// Called after failed assertion or SUCCEED()
void TestSuite::OnTestPartResult(const TestPartResult& test_part_result) {
    this->currentTestInfo->status = !test_part_result.failed();
    this->currentTestInfo->summary = test_part_result.summary();
}