From aef47282ecf147957222381496158ca3016b0ed0 Mon Sep 17 00:00:00 2001 From: Craig Henderson Date: Sat, 12 Oct 2013 10:00:18 +0100 Subject: [PATCH] Eliminated objects that hold constant strings. Aids step-debugging in MSVC --- include/internal/catch_assertionresult.h | 10 +++++----- include/internal/catch_assertionresult.hpp | 14 +++++++------- include/internal/catch_common.h | 8 ++++---- .../internal/catch_expressionresult_builder.hpp | 2 +- include/internal/catch_message.h | 6 +++--- include/internal/catch_message.hpp | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index 7cfe4d83..132d2cba 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -16,14 +16,14 @@ namespace Catch { struct AssertionInfo { AssertionInfo() {} - AssertionInfo( std::string const& _macroName, + AssertionInfo( char const * _macroName, SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, + char const * _capturedExpression, ResultDisposition::Flags _resultDisposition ); - std::string macroName; + char const * macroName; SourceLineInfo lineInfo; - std::string capturedExpression; + char const * capturedExpression; ResultDisposition::Flags resultDisposition; }; @@ -53,7 +53,7 @@ namespace Catch { std::string getExpandedExpression() const; std::string getMessage() const; SourceLineInfo getSourceInfo() const; - std::string getTestMacroName() const; + char const * getTestMacroName() const; protected: AssertionInfo m_info; diff --git a/include/internal/catch_assertionresult.hpp b/include/internal/catch_assertionresult.hpp index 392270d8..4d047e6e 100644 --- a/include/internal/catch_assertionresult.hpp +++ b/include/internal/catch_assertionresult.hpp @@ -13,9 +13,9 @@ namespace Catch { - AssertionInfo::AssertionInfo( std::string const& _macroName, + AssertionInfo::AssertionInfo( char const * _macroName, SourceLineInfo const& _lineInfo, - std::string const& _capturedExpression, + char const * _capturedExpression, ResultDisposition::Flags _resultDisposition ) : macroName( _macroName ), lineInfo( _lineInfo ), @@ -47,7 +47,7 @@ namespace Catch { } bool AssertionResult::hasExpression() const { - return !m_info.capturedExpression.empty(); + return m_info.capturedExpression != 0 && *m_info.capturedExpression != 0; } bool AssertionResult::hasMessage() const { @@ -56,15 +56,15 @@ namespace Catch { std::string AssertionResult::getExpression() const { if( shouldNegate( m_info.resultDisposition ) ) - return "!" + m_info.capturedExpression; + return std::string("!") + m_info.capturedExpression; else return m_info.capturedExpression; } std::string AssertionResult::getExpressionInMacro() const { - if( m_info.macroName.empty() ) + if( m_info.macroName == 0 || *m_info.macroName == 0) return m_info.capturedExpression; else - return m_info.macroName + "( " + m_info.capturedExpression + " )"; + return std::string(m_info.macroName) + "( " + m_info.capturedExpression + " )"; } bool AssertionResult::hasExpandedExpression() const { @@ -82,7 +82,7 @@ namespace Catch { return m_info.lineInfo; } - std::string AssertionResult::getTestMacroName() const { + char const *AssertionResult::getTestMacroName() const { return m_info.macroName; } diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 7759987d..9c35527e 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -105,7 +105,7 @@ namespace Catch { struct SourceLineInfo { SourceLineInfo() : line( 0 ){} - SourceLineInfo( std::string const& _file, std::size_t _line ) + SourceLineInfo( char const * _file, std::size_t _line ) : file( _file ), line( _line ) {} @@ -114,12 +114,12 @@ namespace Catch { line( other.line ) {} bool empty() const { - return file.empty(); + return file == 0 || *file == 0; } bool operator == ( SourceLineInfo const& other ) const { - return line == other.line && file == other.file; + return line == other.line && ((empty() && other.empty()) || strcmp(file, other.file) == 0); } - std::string file; + char const * file; std::size_t line; }; diff --git a/include/internal/catch_expressionresult_builder.hpp b/include/internal/catch_expressionresult_builder.hpp index 2a451ea6..cb6faa0c 100644 --- a/include/internal/catch_expressionresult_builder.hpp +++ b/include/internal/catch_expressionresult_builder.hpp @@ -90,7 +90,7 @@ namespace Catch { return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs; } else - return "{can't expand - use " + info.macroName + "_FALSE( " + info.capturedExpression.substr(1) + " ) instead of " + info.macroName + "( " + info.capturedExpression + " ) for better diagnostics}"; + return "{can't expand - use " + std::string(info.macroName) + "_FALSE( " + *(info.capturedExpression+1) + " ) instead of " + info.macroName + "( " + info.capturedExpression + " ) for better diagnostics}"; } } // end namespace Catch diff --git a/include/internal/catch_message.h b/include/internal/catch_message.h index d0886654..bbef930e 100644 --- a/include/internal/catch_message.h +++ b/include/internal/catch_message.h @@ -15,11 +15,11 @@ namespace Catch { struct MessageInfo { - MessageInfo( std::string const& _macroName, + MessageInfo( char const * _macroName, SourceLineInfo const& _lineInfo, ResultWas::OfType _type ); - std::string macroName; + char const * macroName; SourceLineInfo lineInfo; ResultWas::OfType type; std::string message; @@ -36,7 +36,7 @@ namespace Catch { }; struct MessageBuilder { - MessageBuilder( std::string const& macroName, + MessageBuilder( char const * macroName, SourceLineInfo const& lineInfo, ResultWas::OfType type ) : m_info( macroName, lineInfo, type ) diff --git a/include/internal/catch_message.hpp b/include/internal/catch_message.hpp index 8f303f7a..59d5d740 100644 --- a/include/internal/catch_message.hpp +++ b/include/internal/catch_message.hpp @@ -12,7 +12,7 @@ namespace Catch { - MessageInfo::MessageInfo( std::string const& _macroName, + MessageInfo::MessageInfo( char const * _macroName, SourceLineInfo const& _lineInfo, ResultWas::OfType _type ) : macroName( _macroName ),