Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2017-12-05 16:18:53 +0000
committerPhil Nash2017-12-05 16:23:10 +0000
commit533cdc6bc137381f8a358e15d97289917c2df6c5 (patch)
tree65a8530a9d0dcdeebd838f99323e7196a4fbae56 /include
parent51e281a6842ae4b38120d78154f049275a351894 (diff)
downloadcatch3-533cdc6bc137381f8a358e15d97289917c2df6c5.tar.gz
Revirtualised IResultCapture methods
Didn't really impact runtime anyway, but will need to use interface for threading support.
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_assertionhandler.cpp2
-rw-r--r--include/internal/catch_assertionhandler.h2
-rw-r--r--include/internal/catch_interfaces_capture.h29
-rw-r--r--include/internal/catch_run_context.h53
4 files changed, 57 insertions, 29 deletions
diff --git a/include/internal/catch_assertionhandler.cpp b/include/internal/catch_assertionhandler.cpp
index d7311e9a..4d74dc9c 100644
--- a/include/internal/catch_assertionhandler.cpp
+++ b/include/internal/catch_assertionhandler.cpp
@@ -56,7 +56,7 @@ namespace Catch {
StringRef capturedExpression,
ResultDisposition::Flags resultDisposition )
: m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },
- m_resultCapture( static_cast<RunContext&>( getResultCapture() ) )
+ m_resultCapture( getResultCapture() )
{}
AssertionHandler::~AssertionHandler() {
diff --git a/include/internal/catch_assertionhandler.h b/include/internal/catch_assertionhandler.h
index f05c3b40..fb51f962 100644
--- a/include/internal/catch_assertionhandler.h
+++ b/include/internal/catch_assertionhandler.h
@@ -44,7 +44,7 @@ namespace Catch {
AssertionInfo m_assertionInfo;
AssertionReaction m_reaction;
bool m_completed = false;
- RunContext& m_resultCapture;
+ IResultCapture& m_resultCapture;
public:
AssertionHandler
diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h
index 7234eb4e..4d091f89 100644
--- a/include/internal/catch_interfaces_capture.h
+++ b/include/internal/catch_interfaces_capture.h
@@ -11,6 +11,7 @@
#include <string>
#include "catch_stringref.h"
+#include "catch_result_type.h"
namespace Catch {
@@ -22,6 +23,9 @@ namespace Catch {
struct Counts;
struct BenchmarkInfo;
struct BenchmarkStats;
+ struct AssertionReaction;
+
+ struct ITransientExpression;
struct IResultCapture {
@@ -40,6 +44,31 @@ namespace Catch {
virtual void handleFatalErrorCondition( StringRef message ) = 0;
+ virtual void handleExpr
+ ( AssertionInfo const& info,
+ ITransientExpression const& expr,
+ AssertionReaction& reaction ) = 0;
+ virtual void handleMessage
+ ( AssertionInfo const& info,
+ ResultWas::OfType resultType,
+ StringRef const& message,
+ AssertionReaction& reaction ) = 0;
+ virtual void handleUnexpectedExceptionNotThrown
+ ( AssertionInfo const& info,
+ AssertionReaction& reaction ) = 0;
+ virtual void handleUnexpectedInflightException
+ ( AssertionInfo const& info,
+ std::string const& message,
+ AssertionReaction& reaction ) = 0;
+ virtual void handleIncomplete
+ ( AssertionInfo const& info ) = 0;
+ virtual void handleNonExpr
+ ( AssertionInfo const &info,
+ ResultWas::OfType resultType,
+ AssertionReaction &reaction ) = 0;
+
+
+
virtual bool lastAssertionPassed() = 0;
virtual void assertionPassed() = 0;
diff --git a/include/internal/catch_run_context.h b/include/internal/catch_run_context.h
index 88767711..732caa47 100644
--- a/include/internal/catch_run_context.h
+++ b/include/internal/catch_run_context.h
@@ -63,65 +63,54 @@ namespace Catch {
RunContext( RunContext const& ) = delete;
RunContext& operator =( RunContext const& ) = delete;
- explicit RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter);
+ explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter );
~RunContext() override;
- void testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount);
- void testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount);
+ void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount );
+ void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount );
Totals runTest(TestCase const& testCase);
IConfigPtr config() const;
IStreamingReporter& reporter() const;
+ public: // IResultCapture
+
// Assertion handlers
void handleExpr
( AssertionInfo const& info,
ITransientExpression const& expr,
- AssertionReaction& reaction );
+ AssertionReaction& reaction ) override;
void handleMessage
( AssertionInfo const& info,
ResultWas::OfType resultType,
StringRef const& message,
- AssertionReaction& reaction );
+ AssertionReaction& reaction ) override;
void handleUnexpectedExceptionNotThrown
( AssertionInfo const& info,
- AssertionReaction& reaction );
+ AssertionReaction& reaction ) override;
void handleUnexpectedInflightException
( AssertionInfo const& info,
std::string const& message,
- AssertionReaction& reaction );
+ AssertionReaction& reaction ) override;
void handleIncomplete
- ( AssertionInfo const& info );
+ ( AssertionInfo const& info ) override;
void handleNonExpr
( AssertionInfo const &info,
ResultWas::OfType resultType,
- AssertionReaction &reaction );
-
- void reportExpr
- (AssertionInfo const &info,
- ResultWas::OfType resultType,
- ITransientExpression const *expr,
- bool negated );
-
- void populateReaction( AssertionReaction& reaction );
-
- public: // IResultCapture
-
- void assertionEnded(AssertionResult const& result);
+ AssertionReaction &reaction ) override;
bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override;
- bool testForMissingAssertions(Counts& assertions);
- void sectionEnded(SectionEndInfo const& endInfo) override;
- void sectionEndedEarly(SectionEndInfo const& endInfo) override;
+ void sectionEnded( SectionEndInfo const& endInfo ) override;
+ void sectionEndedEarly( SectionEndInfo const& endInfo ) override;
void benchmarkStarting( BenchmarkInfo const& info ) override;
void benchmarkEnded( BenchmarkStats const& stats ) override;
- void pushScopedMessage(MessageInfo const& message) override;
- void popScopedMessage(MessageInfo const& message) override;
+ void pushScopedMessage( MessageInfo const& message ) override;
+ void popScopedMessage( MessageInfo const& message ) override;
std::string getCurrentTestName() const override;
@@ -141,10 +130,20 @@ namespace Catch {
private:
- void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr);
+ void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr );
void invokeActiveTestCase();
void resetAssertionInfo();
+ bool testForMissingAssertions( Counts& assertions );
+
+ void assertionEnded( AssertionResult const& result );
+ void reportExpr
+ ( AssertionInfo const &info,
+ ResultWas::OfType resultType,
+ ITransientExpression const *expr,
+ bool negated );
+
+ void populateReaction( AssertionReaction& reaction );
private: