TestResult &
TestResult::addFailure( const char *file, unsigned int line,
                        const char *expr )
{
   /// Walks the PredicateContext stack adding them to failures_ if not already added.
   unsigned int nestingLevel = 0;
   PredicateContext *lastNode = rootPredicateNode_.next_;
   for ( ; lastNode != 0; lastNode = lastNode->next_ )
   {
      if ( lastNode->id_ > lastUsedPredicateId_ ) // new PredicateContext
      {
         lastUsedPredicateId_ = lastNode->id_;
         addFailureInfo( lastNode->file_, lastNode->line_, lastNode->expr_,
                         nestingLevel );
         // Link the PredicateContext to the failure for message target when 
         // popping the PredicateContext.
         lastNode->failure_ = &( failures_.back() );
      }
      ++nestingLevel;
   }

   // Adds the failed assertion
   addFailureInfo( file, line, expr, nestingLevel );
   messageTarget_ = &( failures_.back() );
   return *this;
}
// Called from the TestRunnerThread.
void 
TestRunnerModel::addFailure( const CPPUNIT_NS::TestFailure &failure )
{
  addFailureInfo( new TestFailureInfo( failure.failedTest(), 
                                       failure.thrownException(),
                                       failure.isError() ) );
}