mirror of https://github.com/catchorg/Catch2.git
Made macroName and capturedExpression StringRefs
This commit is contained in:
parent
59f9bcf1ed
commit
f8148ebae1
|
@ -14,7 +14,7 @@ namespace Catch {
|
||||||
bool DecomposedExpression::isBinaryExpression() const {
|
bool DecomposedExpression::isBinaryExpression() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertionResultData::negate( bool parenthesize ) {
|
void AssertionResultData::negate( bool parenthesize ) {
|
||||||
negated = !negated;
|
negated = !negated;
|
||||||
parenthesized = parenthesize;
|
parenthesized = parenthesize;
|
||||||
|
@ -68,16 +68,16 @@ namespace Catch {
|
||||||
|
|
||||||
std::string AssertionResult::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
if (isFalseTest(m_info.resultDisposition))
|
if (isFalseTest(m_info.resultDisposition))
|
||||||
return '!' + std::string(m_info.capturedExpression);
|
return '!' + std::string(m_info.capturedExpression.c_str());
|
||||||
else
|
else
|
||||||
return std::string(m_info.capturedExpression);
|
return std::string(m_info.capturedExpression.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssertionResult::getExpressionInMacro() const {
|
std::string AssertionResult::getExpressionInMacro() const {
|
||||||
if( m_info.macroName[0] == 0 )
|
if( m_info.macroName[0] == 0 )
|
||||||
return std::string(m_info.capturedExpression);
|
return std::string(m_info.capturedExpression.c_str());
|
||||||
else
|
else
|
||||||
return std::string(m_info.macroName) + "( " + m_info.capturedExpression + " )";
|
return std::string(m_info.macroName.c_str()) + "( " + m_info.capturedExpression.c_str() + " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssertionResult::hasExpandedExpression() const {
|
bool AssertionResult::hasExpandedExpression() const {
|
||||||
|
@ -96,7 +96,7 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssertionResult::getTestMacroName() const {
|
std::string AssertionResult::getTestMacroName() const {
|
||||||
return m_info.macroName;
|
return m_info.macroName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertionResult::discardDecomposedExpression() const {
|
void AssertionResult::discardDecomposedExpression() const {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "catch_result_type.h"
|
#include "catch_result_type.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
|
#include "catch_stringref.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -39,9 +40,9 @@ namespace Catch {
|
||||||
|
|
||||||
struct AssertionInfo
|
struct AssertionInfo
|
||||||
{
|
{
|
||||||
char const * macroName;
|
StringRef macroName;
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
char const * capturedExpression;
|
StringRef capturedExpression;
|
||||||
ResultDisposition::Flags resultDisposition;
|
ResultDisposition::Flags resultDisposition;
|
||||||
|
|
||||||
AssertionInfo() = delete;
|
AssertionInfo() = delete;
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Catch {
|
||||||
if( assertionResult.hasMessage() ) {
|
if( assertionResult.hasMessage() ) {
|
||||||
// Copy message into messages list.
|
// Copy message into messages list.
|
||||||
// !TBD This should have been done earlier, somewhere
|
// !TBD This should have been done earlier, somewhere
|
||||||
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
|
MessageBuilder builder( assertionResult.getTestMacroName().c_str(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
|
||||||
builder << assertionResult.getMessage();
|
builder << assertionResult.getMessage();
|
||||||
builder.m_info.message = builder.m_stream.str();
|
builder.m_info.message = builder.m_stream.str();
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,9 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResultBuilder::ResultBuilder( char const* macroName,
|
ResultBuilder::ResultBuilder( StringRef macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
StringRef capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition )
|
ResultDisposition::Flags resultDisposition )
|
||||||
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }
|
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ namespace Catch {
|
||||||
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
|
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
|
||||||
AssertionResultData data = m_data;
|
AssertionResultData data = m_data;
|
||||||
data.resultType = ResultWas::Ok;
|
data.resultType = ResultWas::Ok;
|
||||||
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
data.reconstructedExpression = m_assertionInfo.capturedExpression.c_str();
|
||||||
|
|
||||||
std::string actualMessage = Catch::translateActiveException();
|
std::string actualMessage = Catch::translateActiveException();
|
||||||
if( !matcher.match( actualMessage ) ) {
|
if( !matcher.match( actualMessage ) ) {
|
||||||
|
@ -166,7 +166,7 @@ namespace Catch {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::reconstructExpression( std::string& dest ) const {
|
void ResultBuilder::reconstructExpression( std::string& dest ) const {
|
||||||
dest = m_assertionInfo.capturedExpression;
|
dest = m_assertionInfo.capturedExpression.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::setExceptionGuard() {
|
void ResultBuilder::setExceptionGuard() {
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace Catch {
|
||||||
|
|
||||||
class ResultBuilder : public DecomposedExpression {
|
class ResultBuilder : public DecomposedExpression {
|
||||||
public:
|
public:
|
||||||
ResultBuilder( char const* macroName,
|
ResultBuilder( StringRef macroName,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
StringRef capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition);
|
ResultDisposition::Flags resultDisposition);
|
||||||
~ResultBuilder();
|
~ResultBuilder();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue