• 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 
13 #include "catch_stringref.h"
14 #include "catch_result_type.h"
15 
16 namespace Catch {
17 
18     class AssertionResult;
19     struct AssertionInfo;
20     struct SectionInfo;
21     struct SectionEndInfo;
22     struct MessageInfo;
23     struct MessageBuilder;
24     struct Counts;
25     struct BenchmarkInfo;
26     struct BenchmarkStats;
27     struct AssertionReaction;
28     struct SourceLineInfo;
29 
30     struct ITransientExpression;
31     struct IGeneratorTracker;
32 
33     struct IResultCapture {
34 
35         virtual ~IResultCapture();
36 
37         virtual bool sectionStarted(    SectionInfo const& sectionInfo,
38                                         Counts& assertions ) = 0;
39         virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
40         virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
41 
42         virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;
43 
44         virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;
45         virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0;
46 
47         virtual void pushScopedMessage( MessageInfo const& message ) = 0;
48         virtual void popScopedMessage( MessageInfo const& message ) = 0;
49 
50         virtual void emplaceUnscopedMessage( MessageBuilder const& builder ) = 0;
51 
52         virtual void handleFatalErrorCondition( StringRef message ) = 0;
53 
54         virtual void handleExpr
55                 (   AssertionInfo const& info,
56                     ITransientExpression const& expr,
57                     AssertionReaction& reaction ) = 0;
58         virtual void handleMessage
59                 (   AssertionInfo const& info,
60                     ResultWas::OfType resultType,
61                     StringRef const& message,
62                     AssertionReaction& reaction ) = 0;
63         virtual void handleUnexpectedExceptionNotThrown
64                 (   AssertionInfo const& info,
65                     AssertionReaction& reaction ) = 0;
66         virtual void handleUnexpectedInflightException
67                 (   AssertionInfo const& info,
68                     std::string const& message,
69                     AssertionReaction& reaction ) = 0;
70         virtual void handleIncomplete
71                 (   AssertionInfo const& info ) = 0;
72         virtual void handleNonExpr
73                 (   AssertionInfo const &info,
74                     ResultWas::OfType resultType,
75                     AssertionReaction &reaction ) = 0;
76 
77 
78 
79         virtual bool lastAssertionPassed() = 0;
80         virtual void assertionPassed() = 0;
81 
82         // Deprecated, do not use:
83         virtual std::string getCurrentTestName() const = 0;
84         virtual const AssertionResult* getLastResult() const = 0;
85         virtual void exceptionEarlyReported() = 0;
86     };
87 
88     IResultCapture& getResultCapture();
89 }
90 
91 #endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
92