catch_interfaces_capture.h 3.6 KB

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