mirror of https://github.com/catchorg/Catch2.git
Reduced AssertionInfo to a pure record type
This commit is contained in:
parent
5e60050299
commit
59f9bcf1ed
|
@ -14,17 +14,7 @@ namespace Catch {
|
||||||
bool DecomposedExpression::isBinaryExpression() const {
|
bool DecomposedExpression::isBinaryExpression() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
|
||||||
SourceLineInfo const& _lineInfo,
|
|
||||||
char const * _capturedExpression,
|
|
||||||
ResultDisposition::Flags _resultDisposition)
|
|
||||||
: macroName( _macroName ),
|
|
||||||
lineInfo( _lineInfo ),
|
|
||||||
capturedExpression( _capturedExpression ),
|
|
||||||
resultDisposition( _resultDisposition )
|
|
||||||
{}
|
|
||||||
|
|
||||||
void AssertionResultData::negate( bool parenthesize ) {
|
void AssertionResultData::negate( bool parenthesize ) {
|
||||||
negated = !negated;
|
negated = !negated;
|
||||||
parenthesized = parenthesize;
|
parenthesized = parenthesize;
|
||||||
|
@ -54,8 +44,6 @@ namespace Catch {
|
||||||
m_resultData( data )
|
m_resultData( data )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AssertionResult::~AssertionResult() {}
|
|
||||||
|
|
||||||
// Result was a success
|
// Result was a success
|
||||||
bool AssertionResult::succeeded() const {
|
bool AssertionResult::succeeded() const {
|
||||||
return Catch::isOk( m_resultData.resultType );
|
return Catch::isOk( m_resultData.resultType );
|
||||||
|
|
|
@ -39,16 +39,12 @@ namespace Catch {
|
||||||
|
|
||||||
struct AssertionInfo
|
struct AssertionInfo
|
||||||
{
|
{
|
||||||
AssertionInfo() = delete;
|
char const * macroName;
|
||||||
AssertionInfo( char const * _macroName,
|
|
||||||
SourceLineInfo const& _lineInfo,
|
|
||||||
char const * _capturedExpression,
|
|
||||||
ResultDisposition::Flags _resultDisposition);
|
|
||||||
|
|
||||||
char const * macroName = nullptr;
|
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
char const * capturedExpression = nullptr;
|
char const * capturedExpression;
|
||||||
ResultDisposition::Flags resultDisposition = ResultDisposition::Normal;
|
ResultDisposition::Flags resultDisposition;
|
||||||
|
|
||||||
|
AssertionInfo() = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AssertionResultData
|
struct AssertionResultData
|
||||||
|
@ -66,13 +62,8 @@ namespace Catch {
|
||||||
|
|
||||||
class AssertionResult {
|
class AssertionResult {
|
||||||
public:
|
public:
|
||||||
|
AssertionResult() = delete;
|
||||||
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
|
||||||
~AssertionResult();
|
|
||||||
|
|
||||||
AssertionResult( AssertionResult const& ) = default;
|
|
||||||
AssertionResult( AssertionResult && ) = default;
|
|
||||||
AssertionResult& operator = ( AssertionResult const& ) = default;
|
|
||||||
AssertionResult& operator = ( AssertionResult && ) = default;
|
|
||||||
|
|
||||||
bool isOk() const;
|
bool isOk() const;
|
||||||
bool succeeded() const;
|
bool succeeded() const;
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Catch {
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition )
|
ResultDisposition::Flags resultDisposition )
|
||||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition)
|
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }
|
||||||
{
|
{
|
||||||
getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo );
|
getCurrentContext().getResultCapture()->assertionStarting( m_assertionInfo );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Catch {
|
||||||
m_context(getCurrentMutableContext()),
|
m_context(getCurrentMutableContext()),
|
||||||
m_config(_config),
|
m_config(_config),
|
||||||
m_reporter(std::move(reporter)),
|
m_reporter(std::move(reporter)),
|
||||||
m_lastAssertionInfo( "", SourceLineInfo("",0), "", ResultDisposition::Normal )
|
m_lastAssertionInfo{ "", SourceLineInfo("",0), "", ResultDisposition::Normal }
|
||||||
{
|
{
|
||||||
m_context.setRunner(this);
|
m_context.setRunner(this);
|
||||||
m_context.setConfig(m_config);
|
m_context.setConfig(m_config);
|
||||||
|
@ -107,7 +107,7 @@ namespace Catch {
|
||||||
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
|
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
|
||||||
|
|
||||||
// Reset working state
|
// Reset working state
|
||||||
m_lastAssertionInfo = AssertionInfo("", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition);
|
m_lastAssertionInfo = { "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition };
|
||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ namespace Catch {
|
||||||
double duration = 0;
|
double duration = 0;
|
||||||
m_shouldReportUnexpected = true;
|
m_shouldReportUnexpected = true;
|
||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo("TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal);
|
m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal };
|
||||||
|
|
||||||
seedRng(*m_config);
|
seedRng(*m_config);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue