• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Created by Phil on 07/01/2011.
3  *  Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 #ifndef TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
9 #define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
10 
11 #include <string>
12 #include <chrono>
13 
14 #include "catch_stringref.h"
15 #include "catch_result_type.h"
16 
17 namespace Catch {
18 
19     class AssertionResult;
20     struct AssertionInfo;
21     struct SectionInfo;
22     struct SectionEndInfo;
23     struct MessageInfo;
24     struct MessageBuilder;
25     struct Counts;
26     struct AssertionReaction;
27     struct SourceLineInfo;
28 
29     struct ITransientExpression;
30     struct IGeneratorTracker;
31 
32 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
33     struct BenchmarkInfo;
34     template <typename Duration = std::chrono::duration<double, std::nano>>
35     struct BenchmarkStats;
36 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
37 
38     struct IResultCapture {
39 
40         virtual ~IResultCapture();
41 
42         virtual bool sectionStarted(    SectionInfo const& sectionInfo,
43                                         Counts& assertions ) = 0;
44         virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
45         virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
46 
47         virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;
48 
49 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
50         virtual void benchmarkPreparing( std::string const& name ) = 0;
51         virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;
52         virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0;
53         virtual void benchmarkFailed( std::string const& error ) = 0;
54 #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
55 
56         virtual void pushScopedMessage( MessageInfo const& message ) = 0;
57         virtual void popScopedMessage( MessageInfo const& message ) = 0;
58 
59         virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0;
60 
61         virtual void handleFatalErrorCondition( StringRef message ) = 0;
62 
63         virtual void handleExpr
64                 (   AssertionInfo const& info,
65                     ITransientExpression const& expr,
66                     AssertionReaction& reaction ) = 0;
67         virtual void handleMessage
68                 (   AssertionInfo const& info,
69                     ResultWas::OfType resultType,
70                     StringRef const& message,
71                     AssertionReaction& reaction ) = 0;
72         virtual void handleUnexpectedExceptionNotThrown
73                 (   AssertionInfo const& info,
74                     AssertionReaction& reaction ) = 0;
75         virtual void handleUnexpectedInflightException
76                 (   AssertionInfo const& info,
77                     std::string const& message,
78                     AssertionReaction& reaction ) = 0;
79         virtual void handleIncomplete
80                 (   AssertionInfo const& info ) = 0;
81         virtual void handleNonExpr
82                 (   AssertionInfo const &info,
83                     ResultWas::OfType resultType,
84                     AssertionReaction &reaction ) = 0;
85 
86 
87 
88         virtual bool lastAssertionPassed() = 0;
89         virtual void assertionPassed() = 0;
90 
91         // Deprecated, do not use:
92         virtual std::string getCurrentTestName() const = 0;
93         virtual const AssertionResult* getLastResult() const = 0;
94         virtual void exceptionEarlyReported() = 0;
95     };
96 
97     IResultCapture& getResultCapture();
98 }
99 
100 #endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
101