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:
Phil Nash
2014-05-28 18:53:01 +01:00
parent 14796814b8
commit 9438a03d5b
26 changed files with 312 additions and 260 deletions

View File

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