Moved all AssertionHandler logic into RunContext and de-virtualised interface

This makes the assertion handling much less "chatty". AssertionHandler is now just a thin shim over RunContext
This commit is contained in:
Phil Nash
2017-11-27 22:21:47 +03:00
parent 5461242ffe
commit 4b614ee1d1
5 changed files with 179 additions and 81 deletions

View File

@@ -16,10 +16,12 @@ namespace Catch {
struct TestFailureException{};
struct AssertionResultData;
struct IResultCapture;
class RunContext;
class LazyExpression {
friend class AssertionHandler;
friend struct AssertionStats;
friend class RunContext;
ITransientExpression const* m_transientExpression = nullptr;
bool m_isNegated;
@@ -33,12 +35,16 @@ namespace Catch {
friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;
};
struct AssertionReaction {
bool shouldDebugBreak = false;
bool shouldThrow = false;
};
class AssertionHandler {
AssertionInfo m_assertionInfo;
bool m_shouldDebugBreak = false;
bool m_shouldThrow = false;
AssertionReaction m_reaction;
bool m_completed = false;
IResultCapture& m_resultCapture;
RunContext& m_resultCapture;
public:
AssertionHandler
@@ -67,11 +73,6 @@ namespace Catch {
// query
auto allowThrows() const -> bool;
private:
void handle( ResultWas::OfType resultType );
void handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated );
void handle( AssertionResultData const& resultData, ITransientExpression const* expr );
};
void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString );