示例#1
0
    void ResultBuilder::captureExpression() {
        AssertionResult result = build();
        getResultCapture().assertionEnded( result );

        if( !result.isOk() ) {
            if( getCurrentContext().getConfig()->shouldDebugBreak() )
                m_shouldDebugBreak = true;
            if( getCurrentContext().getRunner()->aborting() || m_assertionInfo.resultDisposition == ResultDisposition::Normal )
                m_shouldThrow = true;
        }
    }
示例#2
0
        virtual void assertionEnded( AssertionResult const& result ) {
            if( result.getResultType() == ResultWas::Ok ) {
                m_totals.assertions.passed++;
            }
            else if( !result.isOk() ) {
                m_totals.assertions.failed++;
            }

            if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
                m_messages.clear();

            // Reset working state
            m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
        }
示例#3
0
    void MockReporter::Result( const AssertionResult& assertionResult ) {
        if( assertionResult.getResultType() == ResultWas::Ok )
            return;

        m_log << assertionResult.getSourceInfo() << " ";
        
        switch( assertionResult.getResultType() ) {          
            case ResultWas::Info:
                m_log << "Info";
                break;
            case ResultWas::Warning:
                m_log << "Warning";
                break;
            case ResultWas::ExplicitFailure:
                m_log << "ExplicitFailure";
                break;
            case ResultWas::ExpressionFailed:
                m_log << "ExpressionFailed";
                break;
            case ResultWas::Unknown:
                m_log << "Unknown";
                break;
            case ResultWas::ThrewException:
                m_log << "ThrewException";
                break;
            case ResultWas::DidntThrowException:
                m_log << "DidntThrowException";
                break;

            // We shouldn't ever see these
            case ResultWas::Ok:
                m_log << "Ok";
                break;
            case ResultWas::FailureBit:
                m_log << "FailureBit";
                break;
            case ResultWas::Exception:
                m_log << "Exception";
                break;
        }
        
        if( assertionResult.hasExpression() )
            m_log << assertionResult.getExpression();
        
        if( assertionResult.hasMessage() )
            m_log << "'" << assertionResult.getMessage() << "'";
        
        if( assertionResult.hasExpandedExpression() )
            m_log << assertionResult.getExpandedExpression();        
    }    
        virtual void assertionEnded( AssertionResult const& result ) {
            if( result.getResultType() == ResultWas::Ok ) {
                m_totals.assertions.passed++;
            }
            else if( !result.isOk() ) {
                if( m_activeTestCase->getTestCaseInfo().okToFail() )
                    m_totals.assertions.failedButOk++;
                else
                    m_totals.assertions.failed++;
            }

            // We have no use for the return value (whether messages should be cleared), because messages were made scoped
            // and should be let to clear themselves out.
            static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));

            // Reset working state
            m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
            m_lastResult = result;
        }
 void ResultBuilder::handleResult( AssertionResult const& result )
 {
     getResultCapture().assertionEnded( result );
     
     if( !result.isOk() ) {
         if( getCurrentContext().getConfig()->shouldDebugBreak() )
             m_shouldDebugBreak = true;
         if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
             m_shouldThrow = true;
     }
 }
示例#6
0
GTestString GetBoolAssertionFailureMessage(const AssertionResult& assertion_result,
    const char* expression_text,
    const char* actual_predicate_value,
    const char* expected_predicate_value) {
        const char* actual_message = assertion_result.message();
        Message msg;
        msg << "Value of: " << expression_text
            << "\n  Actual: " << actual_predicate_value;
        if (actual_message[0] != '\0')
            msg << " (" << actual_message << ")";
        msg << "\nExpected: " << expected_predicate_value;
        return msg.GetString();
}
示例#7
0
    void RunContext::assertionEnded(AssertionResult const & result) {
        if (result.getResultType() == ResultWas::Ok) {
            m_totals.assertions.passed++;
            m_lastAssertionPassed = true;
        } else if (!result.isOk()) {
            m_lastAssertionPassed = false;
            if( m_activeTestCase->getTestCaseInfo().okToFail() )
                m_totals.assertions.failedButOk++;
            else
                m_totals.assertions.failed++;
        }
        else {
            m_lastAssertionPassed = true;
        }

        // We have no use for the return value (whether messages should be cleared), because messages were made scoped
        // and should be let to clear themselves out.
        static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));

        // Reset working state
        resetAssertionInfo();
        m_lastResult = result;
    }
 virtual void prepareExpandedExpression( AssertionResult& result ) const {
     if( result.isOk() )
         result.discardDecomposedExpression();
     else
         result.expandDecomposedExpression();
 }