mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fixed some issues caused by single evaluation work
This commit is contained in:
parent
e0e74774e2
commit
2e444861c9
@ -41,15 +41,32 @@ TEST_CASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
TEST_CASE
|
||||
(
|
||||
"./inprogress/succeeding/Tricky/complex lhs",
|
||||
"./inprogress/failing/Tricky/complex lhs",
|
||||
"Where the LHS is not a simple value"
|
||||
)
|
||||
{
|
||||
/*
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
// This only captures part of the expression, but issues a warning about the rest
|
||||
REQUIRE( a == 2 || b == 2 );
|
||||
*/
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
TEST_CASE
|
||||
(
|
||||
"./inprogress/failing/Tricky/complex 2",
|
||||
"Where the LHS is not a simple value"
|
||||
)
|
||||
{
|
||||
/*
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
// This only captures part of the expression, but issues a warning about the rest
|
||||
REQUIRE( a+1 == b-1 );
|
||||
*/
|
||||
}
|
||||
|
||||
struct Opaque
|
||||
|
@ -155,12 +155,13 @@ inline std::string toString
|
||||
return value ? "true" : "false";
|
||||
}
|
||||
|
||||
class TestFailureException
|
||||
struct TestFailureException
|
||||
{
|
||||
};
|
||||
class DummyExceptionType_DontUse
|
||||
struct DummyExceptionType_DontUse
|
||||
{
|
||||
};
|
||||
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
||||
|
||||
class MutableResultInfo : public ResultInfo
|
||||
{
|
||||
@ -211,14 +212,17 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template<typename RhsT>
|
||||
MutableResultInfo& operator ||
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator ||
|
||||
(
|
||||
const RhsT&
|
||||
)
|
||||
{
|
||||
m_expressionIncomplete = true;
|
||||
return *this;
|
||||
}
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator &&
|
||||
(
|
||||
const RhsT&
|
||||
);
|
||||
|
||||
private:
|
||||
friend class ResultBuilder;
|
||||
@ -251,6 +255,7 @@ private:
|
||||
m_op = OperatorTraits<Op>::getName();
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -335,6 +340,20 @@ public:
|
||||
return m_result.captureBoolExpression( m_lhs );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator +
|
||||
(
|
||||
const RhsT&
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template<typename RhsT>
|
||||
STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator -
|
||||
(
|
||||
const RhsT&
|
||||
);
|
||||
|
||||
private:
|
||||
MutableResultInfo& m_result;
|
||||
const T& m_lhs;
|
||||
|
@ -27,6 +27,7 @@ struct ResultWas{ enum OfType
|
||||
|
||||
ExpressionFailed = FailureBit | 1,
|
||||
ExplicitFailure = FailureBit | 2,
|
||||
ExpressionTooComplex = FailureBit | 3,
|
||||
|
||||
Exception = 0x110,
|
||||
|
||||
|
@ -26,8 +26,7 @@ namespace Catch
|
||||
()
|
||||
: m_line( 0 ),
|
||||
m_result( ResultWas::Unknown ),
|
||||
m_isNot( false ),
|
||||
m_expressionIncomplete( false )
|
||||
m_isNot( false )
|
||||
{}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -48,8 +47,7 @@ namespace Catch
|
||||
m_op( isNotExpression( expr ) ? "!" : "" ),
|
||||
m_message( message ),
|
||||
m_result( result ),
|
||||
m_isNot( isNot ),
|
||||
m_expressionIncomplete( false )
|
||||
m_isNot( isNot )
|
||||
{
|
||||
if( isNot )
|
||||
m_expr = "!" + m_expr;
|
||||
@ -103,8 +101,8 @@ namespace Catch
|
||||
if( !hasExpression() )
|
||||
return "";
|
||||
|
||||
return m_expressionIncomplete
|
||||
? getExpandedExpressionInternal() + " {can't expand the rest of the expression - consider rewriting it}"
|
||||
return m_result == ResultWas::ExpressionTooComplex
|
||||
? getExpandedExpressionInternal() + " {couldn't fully decompose the expression to evaluate it - please rewrite as a binary comparison}"
|
||||
: getExpandedExpressionInternal();
|
||||
}
|
||||
|
||||
@ -172,7 +170,6 @@ namespace Catch
|
||||
std::string m_message;
|
||||
ResultWas::OfType m_result;
|
||||
bool m_isNot;
|
||||
bool m_expressionIncomplete;
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
Loading…
Reference in New Issue
Block a user