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 Counts;
24     struct BenchmarkInfo;
25     struct BenchmarkStats;
26     struct AssertionReaction;
27 
28     struct ITransientExpression;
29 
30     struct IResultCapture {
31 
32         virtual ~IResultCapture();
33 
34         virtual bool sectionStarted(    SectionInfo const& sectionInfo,
35                                         Counts& assertions ) = 0;
36         virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
37         virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
38 
39         virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;
40         virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0;
41 
42         virtual void pushScopedMessage( MessageInfo const& message ) = 0;
43         virtual void popScopedMessage( MessageInfo const& message ) = 0;
44 
45         virtual void handleFatalErrorCondition( StringRef message ) = 0;
46 
47         virtual void handleExpr
48                 (   AssertionInfo const& info,
49                     ITransientExpression const& expr,
50                     AssertionReaction& reaction ) = 0;
51         virtual void handleMessage
52                 (   AssertionInfo const& info,
53                     ResultWas::OfType resultType,
54                     StringRef const& message,
55                     AssertionReaction& reaction ) = 0;
56         virtual void handleUnexpectedExceptionNotThrown
57                 (   AssertionInfo const& info,
58                     AssertionReaction& reaction ) = 0;
59         virtual void handleUnexpectedInflightException
60                 (   AssertionInfo const& info,
61                     std::string const& message,
62                     AssertionReaction& reaction ) = 0;
63         virtual void handleIncomplete
64                 (   AssertionInfo const& info ) = 0;
65         virtual void handleNonExpr
66                 (   AssertionInfo const &info,
67                     ResultWas::OfType resultType,
68                     AssertionReaction &reaction ) = 0;
69 
70 
71 
72         virtual bool lastAssertionPassed() = 0;
73         virtual void assertionPassed() = 0;
74 
75         // Deprecated, do not use:
76         virtual std::string getCurrentTestName() const = 0;
77         virtual const AssertionResult* getLastResult() const = 0;
78         virtual void exceptionEarlyReported() = 0;
79     };
80 
81     IResultCapture& getResultCapture();
82 }
83 
84 #endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
85