Ejemplo n.º 1
0
void AssertionManager::do_assert ( bool condition,
                                   const char * cond_str,
                                   const char * file,
                                   int line,
                                   const char * func,
                                   const char * desc )
{
  if ( (!condition) && AssertionManager::instance().DoAssertions )
  {
    CodeLocation code_position (file,line,func);

    std::ostringstream oss;
    oss << "Assertion failed on rank " << PE::Comm::instance().rank() << ": [" << cond_str << "] ";

    if (desc)
      oss << "'" << desc << "' ";

    oss << "at " << code_position.str();

    if ( AssertionManager::instance().AssertionDumps )
      oss << "\n" << OSystem::instance().layer()->back_trace();

    if ( AssertionManager::instance().AssertionThrows )
    {
      throw FailedAssertion ( code_position, oss.str());
    }
    else
    {
      CFerror.setFilterRankZero(false);
      CFerror << oss.str() << CFendl;
      CFerror << "aborting..." << CFendl;
      abort ();
    }
  }
}
Ejemplo n.º 2
0
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 bool CSReporter::assertionEnded(const Catch::AssertionStats& in_assertionStats) noexcept
 {
     const Catch::AssertionResult& assertionResult = in_assertionStats.assertionResult;
     
     if (isOk(assertionResult.getResultType()) == false)
     {
         m_currentFailedAssertions.push_back(FailedAssertion(assertionResult.getSourceInfo().file, u32(assertionResult.getSourceInfo().line), assertionResult.getExpression()));
     }
     
     return true;
 }