mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-19 11:25:38 +02:00
Big assertion capture refactoring.
- moved as much logic out of the macros as possible - moved most logic into new ResultBuilder class, which wraps ExpressionResultBuilder (may take it over next), subsumes ResultAction and also takes place of ExpressionDecomposer. This introduces many SRP violations - but all in the name of minimising macro logic!
This commit is contained in:
@@ -17,15 +17,16 @@
|
||||
namespace Catch {
|
||||
|
||||
struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
|
||||
struct ResultBuilder;
|
||||
|
||||
// Wraps the (stringised versions of) the lhs, operator and rhs of an expression - as well as
|
||||
// the result of evaluating it. This is used to build an AssertionResult object
|
||||
class ExpressionResultBuilder {
|
||||
public:
|
||||
|
||||
ExpressionResultBuilder( ResultWas::OfType resultType = ResultWas::Unknown );
|
||||
ExpressionResultBuilder( ResultBuilder* rb, ResultWas::OfType resultType = ResultWas::Unknown );
|
||||
ExpressionResultBuilder( ExpressionResultBuilder const& other );
|
||||
ExpressionResultBuilder& operator=(ExpressionResultBuilder const& other );
|
||||
ExpressionResultBuilder& operator=( ExpressionResultBuilder const& other );
|
||||
|
||||
ExpressionResultBuilder& setResultType( ResultWas::OfType result );
|
||||
ExpressionResultBuilder& setResultType( bool result );
|
||||
@@ -33,7 +34,7 @@ public:
|
||||
ExpressionResultBuilder& setRhs( std::string const& rhs );
|
||||
ExpressionResultBuilder& setOp( std::string const& op );
|
||||
|
||||
ExpressionResultBuilder& endExpression( ResultDisposition::Flags resultDisposition );
|
||||
void endExpression();
|
||||
|
||||
template<typename T>
|
||||
ExpressionResultBuilder& operator << ( T const& value ) {
|
||||
@@ -49,6 +50,7 @@ public:
|
||||
template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
|
||||
|
||||
private:
|
||||
ResultBuilder* m_rb;
|
||||
AssertionResultData m_data;
|
||||
struct ExprComponents {
|
||||
ExprComponents() : shouldNegate( false ) {}
|
||||
|
Reference in New Issue
Block a user