Eliminated objects that hold constant strings. Aids step-debugging in MSVC

This commit is contained in:
Craig Henderson 2013-10-12 10:00:18 +01:00
parent 1fe459572e
commit aef47282ec
6 changed files with 21 additions and 21 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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

View File

@ -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 )

View File

@ -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 ),