mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 10:25:39 +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:
49
include/internal/catch_result_builder.h
Normal file
49
include/internal/catch_result_builder.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Created by Phil on 28/5/2014.
|
||||
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
|
||||
|
||||
#include "catch_expression_lhs.hpp"
|
||||
#include "catch_expressionresult_builder.h"
|
||||
#include "catch_common.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct TestFailureException{};
|
||||
|
||||
struct ResultBuilder {
|
||||
ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition );
|
||||
|
||||
template<typename T>
|
||||
ExpressionLhs<T const&> operator->* ( T const& operand ) {
|
||||
return ExpressionLhs<T const&>( *this, operand );
|
||||
}
|
||||
|
||||
ExpressionLhs<bool> operator->* ( bool value ) {
|
||||
return ExpressionLhs<bool>( *this, value );
|
||||
}
|
||||
|
||||
void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
|
||||
void captureResult( ResultWas::OfType resultType );
|
||||
void captureExpression();
|
||||
void react();
|
||||
bool shouldDebugBreak() const;
|
||||
bool allowThrows() const;
|
||||
|
||||
AssertionInfo m_assertionInfo;
|
||||
ExpressionResultBuilder m_resultBuilder;
|
||||
bool m_shouldDebugBreak;
|
||||
bool m_shouldThrow;
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
|
Reference in New Issue
Block a user