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

summaryrefslogtreecommitdiffhomepage
path: root/extras/catch_amalgamated.hpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-07-13 13:37:30 +0200
committerMartin Hořeňovský2023-07-13 13:37:30 +0200
commit6e79e682b726f524310d55dec8ddac4e9c52fb5f (patch)
treef399bdefd6361f173bb36f611d14ee5665e81383 /extras/catch_amalgamated.hpp
parent683c85772f65a8779e3baf45d3402098db58bb8d (diff)
downloadcatch3-3.4.0.tar.gz
v3.4.0v3.4.0
Diffstat (limited to 'extras/catch_amalgamated.hpp')
-rw-r--r--extras/catch_amalgamated.hpp2517
1 files changed, 1344 insertions, 1173 deletions
diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp
index 321cec5d..694fe1e4 100644
--- a/extras/catch_amalgamated.hpp
+++ b/extras/catch_amalgamated.hpp
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: BSL-1.0
-// Catch v3.3.2
-// Generated: 2023-02-26 10:28:46.785908
+// Catch v3.4.0
+// Generated: 2023-07-13 13:23:07.577770
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -59,238 +59,6 @@
-#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED
-#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED
-
-
-
-#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED
-#define CATCH_NONCOPYABLE_HPP_INCLUDED
-
-namespace Catch {
- namespace Detail {
-
- //! Deriving classes become noncopyable and nonmovable
- class NonCopyable {
- NonCopyable( NonCopyable const& ) = delete;
- NonCopyable( NonCopyable&& ) = delete;
- NonCopyable& operator=( NonCopyable const& ) = delete;
- NonCopyable& operator=( NonCopyable&& ) = delete;
-
- protected:
- NonCopyable() noexcept = default;
- };
-
- } // namespace Detail
-} // namespace Catch
-
-#endif // CATCH_NONCOPYABLE_HPP_INCLUDED
-
-
-#ifndef CATCH_STRINGREF_HPP_INCLUDED
-#define CATCH_STRINGREF_HPP_INCLUDED
-
-#include <cstddef>
-#include <string>
-#include <iosfwd>
-#include <cassert>
-
-#include <cstring>
-
-namespace Catch {
-
- /// A non-owning string class (similar to the forthcoming std::string_view)
- /// Note that, because a StringRef may be a substring of another string,
- /// it may not be null terminated.
- class StringRef {
- public:
- using size_type = std::size_t;
- using const_iterator = const char*;
-
- private:
- static constexpr char const* const s_empty = "";
-
- char const* m_start = s_empty;
- size_type m_size = 0;
-
- public: // construction
- constexpr StringRef() noexcept = default;
-
- StringRef( char const* rawChars ) noexcept;
-
- constexpr StringRef( char const* rawChars, size_type size ) noexcept
- : m_start( rawChars ),
- m_size( size )
- {}
-
- StringRef( std::string const& stdString ) noexcept
- : m_start( stdString.c_str() ),
- m_size( stdString.size() )
- {}
-
- explicit operator std::string() const {
- return std::string(m_start, m_size);
- }
-
- public: // operators
- auto operator == ( StringRef other ) const noexcept -> bool {
- return m_size == other.m_size
- && (std::memcmp( m_start, other.m_start, m_size ) == 0);
- }
- auto operator != (StringRef other) const noexcept -> bool {
- return !(*this == other);
- }
-
- constexpr auto operator[] ( size_type index ) const noexcept -> char {
- assert(index < m_size);
- return m_start[index];
- }
-
- bool operator<(StringRef rhs) const noexcept;
-
- public: // named queries
- constexpr auto empty() const noexcept -> bool {
- return m_size == 0;
- }
- constexpr auto size() const noexcept -> size_type {
- return m_size;
- }
-
- // Returns a substring of [start, start + length).
- // If start + length > size(), then the substring is [start, start + size()).
- // If start > size(), then the substring is empty.
- constexpr StringRef substr(size_type start, size_type length) const noexcept {
- if (start < m_size) {
- const auto shortened_size = m_size - start;
- return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length);
- } else {
- return StringRef();
- }
- }
-
- // Returns the current start pointer. May not be null-terminated.
- constexpr char const* data() const noexcept {
- return m_start;
- }
-
- constexpr const_iterator begin() const { return m_start; }
- constexpr const_iterator end() const { return m_start + m_size; }
-
-
- friend std::string& operator += (std::string& lhs, StringRef sr);
- friend std::ostream& operator << (std::ostream& os, StringRef sr);
- friend std::string operator+(StringRef lhs, StringRef rhs);
-
- /**
- * Provides a three-way comparison with rhs
- *
- * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive
- * number if lhs > rhs
- */
- int compare( StringRef rhs ) const;
- };
-
-
- constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
- return StringRef( rawChars, size );
- }
-} // namespace Catch
-
-constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
- return Catch::StringRef( rawChars, size );
-}
-
-#endif // CATCH_STRINGREF_HPP_INCLUDED
-
-#include <chrono>
-#include <iosfwd>
-#include <string>
-#include <vector>
-
-namespace Catch {
-
- enum class Verbosity {
- Quiet = 0,
- Normal,
- High
- };
-
- struct WarnAbout { enum What {
- Nothing = 0x00,
- //! A test case or leaf section did not run any assertions
- NoAssertions = 0x01,
- //! A command line test spec matched no test cases
- UnmatchedTestSpec = 0x02,
- }; };
-
- enum class ShowDurations {
- DefaultForReporter,
- Always,
- Never
- };
- enum class TestRunOrder {
- Declared,
- LexicographicallySorted,
- Randomized
- };
- enum class ColourMode : std::uint8_t {
- //! Let Catch2 pick implementation based on platform detection
- PlatformDefault,
- //! Use ANSI colour code escapes
- ANSI,
- //! Use Win32 console colour API
- Win32,
- //! Don't use any colour
- None
- };
- struct WaitForKeypress { enum When {
- Never,
- BeforeStart = 1,
- BeforeExit = 2,
- BeforeStartAndExit = BeforeStart | BeforeExit
- }; };
-
- class TestSpec;
- class IStream;
-
- class IConfig : public Detail::NonCopyable {
- public:
- virtual ~IConfig();
-
- virtual bool allowThrows() const = 0;
- virtual StringRef name() const = 0;
- virtual bool includeSuccessfulResults() const = 0;
- virtual bool shouldDebugBreak() const = 0;
- virtual bool warnAboutMissingAssertions() const = 0;
- virtual bool warnAboutUnmatchedTestSpecs() const = 0;
- virtual bool zeroTestsCountAsSuccess() const = 0;
- virtual int abortAfter() const = 0;
- virtual bool showInvisibles() const = 0;
- virtual ShowDurations showDurations() const = 0;
- virtual double minDuration() const = 0;
- virtual TestSpec const& testSpec() const = 0;
- virtual bool hasTestFilters() const = 0;
- virtual std::vector<std::string> const& getTestsOrTags() const = 0;
- virtual TestRunOrder runOrder() const = 0;
- virtual uint32_t rngSeed() const = 0;
- virtual unsigned int shardCount() const = 0;
- virtual unsigned int shardIndex() const = 0;
- virtual ColourMode defaultColourMode() const = 0;
- virtual std::vector<std::string> const& getSectionsToRun() const = 0;
- virtual Verbosity verbosity() const = 0;
-
- virtual bool skipBenchmarks() const = 0;
- virtual bool benchmarkNoAnalysis() const = 0;
- virtual unsigned int benchmarkSamples() const = 0;
- virtual double benchmarkConfidenceInterval() const = 0;
- virtual unsigned int benchmarkResamples() const = 0;
- virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0;
- };
-}
-
-#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED
-
-
#ifndef CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
#define CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
@@ -366,12 +134,18 @@ namespace Catch {
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT \
+ _Pragma( "GCC diagnostic ignored \"-Wunused-result\"" )
+
# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
_Pragma( "GCC diagnostic ignored \"-Wunused-variable\"" )
# define CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \
_Pragma( "GCC diagnostic ignored \"-Wuseless-cast\"" )
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
+ _Pragma( "GCC diagnostic ignored \"-Wshadow\"" )
+
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
#endif
@@ -444,6 +218,9 @@ namespace Catch {
# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS \
_Pragma( "clang diagnostic ignored \"-Wcomma\"" )
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
+ _Pragma( "clang diagnostic ignored \"-Wshadow\"" )
+
#endif // __clang__
@@ -681,6 +458,9 @@ namespace Catch {
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
#endif
+#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT)
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_RESULT
+#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS
#endif
@@ -690,6 +470,16 @@ namespace Catch {
#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS
#endif
+#if !defined( CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS )
+# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
+#endif
+#if !defined( CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS )
+# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS
+#endif
+#if !defined( CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS )
+# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS
+#endif
+
// The goal of this macro is to avoid evaluation of the arguments, but
// still have the compiler warn on problems inside...
@@ -703,13 +493,6 @@ namespace Catch {
# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
#endif
-#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
-#endif
-
-#if !defined(CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_COMMA_WARNINGS
-#endif
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
#define CATCH_TRY if ((true))
@@ -755,38 +538,31 @@ namespace Catch {
class IResultCapture;
class IConfig;
- class IContext {
- public:
- virtual ~IContext(); // = default
+ class Context {
+ IConfig const* m_config = nullptr;
+ IResultCapture* m_resultCapture = nullptr;
- virtual IResultCapture* getResultCapture() = 0;
- virtual IConfig const* getConfig() const = 0;
- };
+ CATCH_EXPORT static Context* currentContext;
+ friend Context& getCurrentMutableContext();
+ friend Context const& getCurrentContext();
+ static void createContext();
+ friend void cleanUpContext();
- class IMutableContext : public IContext {
public:
- ~IMutableContext() override; // = default
- virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
- virtual void setConfig( IConfig const* config ) = 0;
-
- private:
- CATCH_EXPORT static IMutableContext* currentContext;
- friend IMutableContext& getCurrentMutableContext();
- friend void cleanUpContext();
- static void createContext();
+ IResultCapture* getResultCapture() const { return m_resultCapture; }
+ IConfig const* getConfig() const { return m_config; }
+ void setResultCapture( IResultCapture* resultCapture );
+ void setConfig( IConfig const* config );
};
- inline IMutableContext& getCurrentMutableContext()
- {
- if( !IMutableContext::currentContext )
- IMutableContext::createContext();
- // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
- return *IMutableContext::currentContext;
- }
+ Context& getCurrentMutableContext();
- inline IContext& getCurrentContext()
- {
- return getCurrentMutableContext();
+ inline Context const& getCurrentContext() {
+ // We duplicate the logic from `getCurrentMutableContext` here,
+ // to avoid paying the call overhead in debug mode.
+ if ( !Context::currentContext ) { Context::createContext(); }
+ // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
+ return *Context::currentContext;
}
void cleanUpContext();
@@ -798,16 +574,6 @@ namespace Catch {
#endif // CATCH_CONTEXT_HPP_INCLUDED
-#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED
-#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED
-
-
-
-#ifndef CATCH_SECTION_INFO_HPP_INCLUDED
-#define CATCH_SECTION_INFO_HPP_INCLUDED
-
-
-
#ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED
#define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED
@@ -822,110 +588,199 @@ namespace Catch {
#endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED
-#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
-#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
-
-#include <cstddef>
-#include <iosfwd>
+#ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
+#define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
namespace Catch {
- struct SourceLineInfo {
+ //! Used to signal that an assertion macro failed
+ struct TestFailureException{};
+ //! Used to signal that the remainder of a test should be skipped
+ struct TestSkipException {};
- SourceLineInfo() = delete;
- constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept:
- file( _file ),
- line( _line )
- {}
+ /**
+ * Outlines throwing of `TestFailureException` into a single TU
+ *
+ * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers.
+ */
+ [[noreturn]] void throw_test_failure_exception();
- bool operator == ( SourceLineInfo const& other ) const noexcept;
- bool operator < ( SourceLineInfo const& other ) const noexcept;
+ /**
+ * Outlines throwing of `TestSkipException` into a single TU
+ *
+ * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers.
+ */
+ [[noreturn]] void throw_test_skip_exception();
- char const* file;
- std::size_t line;
+} // namespace Catch
- friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info);
- };
-}
+#endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED
-#define CATCH_INTERNAL_LINEINFO \
- ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
-#endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
+#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED
+#define CATCH_UNIQUE_NAME_HPP_INCLUDED
-#ifndef CATCH_TOTALS_HPP_INCLUDED
-#define CATCH_TOTALS_HPP_INCLUDED
-#include <cstdint>
-namespace Catch {
+/** \file
+ * Wrapper for the CONFIG configuration option
+ *
+ * When generating internal unique names, there are two options. Either
+ * we mix in the current line number, or mix in an incrementing number.
+ * We prefer the latter, using `__COUNTER__`, but users might want to
+ * use the former.
+ */
- struct Counts {
- Counts operator - ( Counts const& other ) const;
- Counts& operator += ( Counts const& other );
+#ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED
+#define CATCH_CONFIG_COUNTER_HPP_INCLUDED
- std::uint64_t total() const;
- bool allPassed() const;
- bool allOk() const;
- std::uint64_t passed = 0;
- std::uint64_t failed = 0;
- std::uint64_t failedButOk = 0;
- std::uint64_t skipped = 0;
- };
+#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
+ #define CATCH_INTERNAL_CONFIG_COUNTER
+#endif
- struct Totals {
+#if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \
+ !defined( CATCH_CONFIG_NO_COUNTER ) && \
+ !defined( CATCH_CONFIG_COUNTER )
+# define CATCH_CONFIG_COUNTER
+#endif
- Totals operator - ( Totals const& other ) const;
- Totals& operator += ( Totals const& other );
- Totals delta( Totals const& prevTotals ) const;
+#endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
+#ifdef CATCH_CONFIG_COUNTER
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
+#else
+# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
+#endif
- Counts assertions;
- Counts testCases;
- };
-}
+#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED
-#endif // CATCH_TOTALS_HPP_INCLUDED
+
+#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
+#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
#include <string>
+#include <chrono>
+
+
+
+#ifndef CATCH_STRINGREF_HPP_INCLUDED
+#define CATCH_STRINGREF_HPP_INCLUDED
+
+#include <cstddef>
+#include <string>
+#include <iosfwd>
+#include <cassert>
+
+#include <cstring>
namespace Catch {
- struct SectionInfo {
- // The last argument is ignored, so that people can write
- // SECTION("ShortName", "Proper description that is long") and
- // still use the `-c` flag comfortably.
- SectionInfo( SourceLineInfo const& _lineInfo, std::string _name,
- const char* const = nullptr ):
- name(CATCH_MOVE(_name)),
- lineInfo(_lineInfo)
- {}
+ /// A non-owning string class (similar to the forthcoming std::string_view)
+ /// Note that, because a StringRef may be a substring of another string,
+ /// it may not be null terminated.
+ class StringRef {
+ public:
+ using size_type = std::size_t;
+ using const_iterator = const char*;
- std::string name;
- SourceLineInfo lineInfo;
- };
+ private:
+ static constexpr char const* const s_empty = "";
- struct SectionEndInfo {
- SectionInfo sectionInfo;
- Counts prevAssertions;
- double durationInSeconds;
- };
+ char const* m_start = s_empty;
+ size_type m_size = 0;
-} // end namespace Catch
+ public: // construction
+ constexpr StringRef() noexcept = default;
-#endif // CATCH_SECTION_INFO_HPP_INCLUDED
+ StringRef( char const* rawChars ) noexcept;
+ constexpr StringRef( char const* rawChars, size_type size ) noexcept
+ : m_start( rawChars ),
+ m_size( size )
+ {}
-#ifndef CATCH_ASSERTION_RESULT_HPP_INCLUDED
-#define CATCH_ASSERTION_RESULT_HPP_INCLUDED
+ StringRef( std::string const& stdString ) noexcept
+ : m_start( stdString.c_str() ),
+ m_size( stdString.size() )
+ {}
+ explicit operator std::string() const {
+ return std::string(m_start, m_size);
+ }
+ public: // operators
+ auto operator == ( StringRef other ) const noexcept -> bool {
+ return m_size == other.m_size
+ && (std::memcmp( m_start, other.m_start, m_size ) == 0);
+ }
+ auto operator != (StringRef other) const noexcept -> bool {
+ return !(*this == other);
+ }
-#ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED
-#define CATCH_ASSERTION_INFO_HPP_INCLUDED
+ constexpr auto operator[] ( size_type index ) const noexcept -> char {
+ assert(index < m_size);
+ return m_start[index];
+ }
+
+ bool operator<(StringRef rhs) const noexcept;
+
+ public: // named queries
+ constexpr auto empty() const noexcept -> bool {
+ return m_size == 0;
+ }
+ constexpr auto size() const noexcept -> size_type {
+ return m_size;
+ }
+
+ // Returns a substring of [start, start + length).
+ // If start + length > size(), then the substring is [start, start + size()).
+ // If start > size(), then the substring is empty.
+ constexpr StringRef substr(size_type start, size_type length) const noexcept {
+ if (start < m_size) {
+ const auto shortened_size = m_size - start;
+ return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length);
+ } else {
+ return StringRef();
+ }
+ }
+
+ // Returns the current start pointer. May not be null-terminated.
+ constexpr char const* data() const noexcept {
+ return m_start;
+ }
+ constexpr const_iterator begin() const { return m_start; }
+ constexpr const_iterator end() const { return m_start + m_size; }
+
+
+ friend std::string& operator += (std::string& lhs, StringRef sr);
+ friend std::ostream& operator << (std::ostream& os, StringRef sr);
+ friend std::string operator+(StringRef lhs, StringRef rhs);
+
+ /**
+ * Provides a three-way comparison with rhs
+ *
+ * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive
+ * number if lhs > rhs
+ */
+ int compare( StringRef rhs ) const;
+ };
+
+
+ constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
+ return StringRef( rawChars, size );
+ }
+} // namespace Catch
+
+constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
+ return Catch::StringRef( rawChars, size );
+}
+
+#endif // CATCH_STRINGREF_HPP_INCLUDED
#ifndef CATCH_RESULT_TYPE_HPP_INCLUDED
@@ -979,114 +834,6 @@ namespace Catch {
#endif // CATCH_RESULT_TYPE_HPP_INCLUDED
-namespace Catch {
-
- struct AssertionInfo {
- // AssertionInfo() = delete;
-
- StringRef macroName;
- SourceLineInfo lineInfo;
- StringRef capturedExpression;
- ResultDisposition::Flags resultDisposition;
- };
-
-} // end namespace Catch
-
-#endif // CATCH_ASSERTION_INFO_HPP_INCLUDED
-
-
-#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED
-#define CATCH_LAZY_EXPR_HPP_INCLUDED
-
-#include <iosfwd>
-
-namespace Catch {
-
- class ITransientExpression;
-
- class LazyExpression {
- friend class AssertionHandler;
- friend struct AssertionStats;
- friend class RunContext;
-
- ITransientExpression const* m_transientExpression = nullptr;
- bool m_isNegated;
- public:
- LazyExpression( bool isNegated ):
- m_isNegated(isNegated)
- {}
- LazyExpression(LazyExpression const& other) = default;
- LazyExpression& operator = ( LazyExpression const& ) = delete;
-
- explicit operator bool() const {
- return m_transientExpression != nullptr;
- }
-
- friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;
- };
-
-} // namespace Catch
-
-#endif // CATCH_LAZY_EXPR_HPP_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- struct AssertionResultData
- {
- AssertionResultData() = delete;
-
- AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression );
-
- std::string message;
- mutable std::string reconstructedExpression;
- LazyExpression lazyExpression;
- ResultWas::OfType resultType;
-
- std::string reconstructExpression() const;
- };
-
- class AssertionResult {
- public:
- AssertionResult() = delete;
- AssertionResult( AssertionInfo const& info, AssertionResultData&& data );
-
- bool isOk() const;
- bool succeeded() const;
- ResultWas::OfType getResultType() const;
- bool hasExpression() const;
- bool hasMessage() const;
- std::string getExpression() const;
- std::string getExpressionInMacro() const;
- bool hasExpandedExpression() const;
- std::string getExpandedExpression() const;
- StringRef getMessage() const;
- SourceLineInfo getSourceInfo() const;
- StringRef getTestMacroName() const;
-
- //protected:
- AssertionInfo m_info;
- AssertionResultData m_resultData;
- };
-
-} // end namespace Catch
-
-#endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED
-
-
-#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
-#define CATCH_MESSAGE_INFO_HPP_INCLUDED
-
-
-
-#ifndef CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
-#define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
-
-#include <string>
-#include <chrono>
-
-
#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED
#define CATCH_UNIQUE_PTR_HPP_INCLUDED
@@ -1199,6 +946,24 @@ namespace Detail {
#endif // CATCH_UNIQUE_PTR_HPP_INCLUDED
+
+#ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
+#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
+
+#include <chrono>
+
+namespace Catch {
+
+ // We cannot forward declare the type with default template argument
+ // multiple times, so it is split out into a separate header so that
+ // we can prevent multiple declarations in dependees
+ template <typename Duration = std::chrono::duration<double, std::nano>>
+ struct BenchmarkStats;
+
+} // end namespace Catch
+
+#endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
+
namespace Catch {
class AssertionResult;
@@ -1215,8 +980,6 @@ namespace Catch {
class IGeneratorTracker;
struct BenchmarkInfo;
- template <typename Duration = std::chrono::duration<double, std::nano>>
- struct BenchmarkStats;
namespace Generators {
class GeneratorUntypedBase;
@@ -1228,6 +991,7 @@ namespace Catch {
public:
virtual ~IResultCapture();
+ virtual void notifyAssertionStarted( AssertionInfo const& info ) = 0;
virtual bool sectionStarted( StringRef sectionName,
SourceLineInfo const& sectionLineInfo,
Counts& assertions ) = 0;
@@ -1268,7 +1032,7 @@ namespace Catch {
AssertionReaction& reaction ) = 0;
virtual void handleUnexpectedInflightException
( AssertionInfo const& info,
- std::string const& message,
+ std::string&& message,
AssertionReaction& reaction ) = 0;
virtual void handleIncomplete
( AssertionInfo const& info ) = 0;
@@ -1293,34 +1057,186 @@ namespace Catch {
#endif // CATCH_INTERFACES_CAPTURE_HPP_INCLUDED
+
+#ifndef CATCH_INTERFACES_CONFIG_HPP_INCLUDED
+#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED
+
+
+
+#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED
+#define CATCH_NONCOPYABLE_HPP_INCLUDED
+
+namespace Catch {
+ namespace Detail {
+
+ //! Deriving classes become noncopyable and nonmovable
+ class NonCopyable {
+ NonCopyable( NonCopyable const& ) = delete;
+ NonCopyable( NonCopyable&& ) = delete;
+ NonCopyable& operator=( NonCopyable const& ) = delete;
+ NonCopyable& operator=( NonCopyable&& ) = delete;
+
+ protected:
+ NonCopyable() noexcept = default;
+ };
+
+ } // namespace Detail
+} // namespace Catch
+
+#endif // CATCH_NONCOPYABLE_HPP_INCLUDED
+
+#include <chrono>
+#include <iosfwd>
#include <string>
+#include <vector>
namespace Catch {
- struct MessageInfo {
- MessageInfo( StringRef _macroName,
- SourceLineInfo const& _lineInfo,
- ResultWas::OfType _type );
+ enum class Verbosity {
+ Quiet = 0,
+ Normal,
+ High
+ };
- StringRef macroName;
- std::string message;
- SourceLineInfo lineInfo;
- ResultWas::OfType type;
- unsigned int sequence;
+ struct WarnAbout { enum What {
+ Nothing = 0x00,
+ //! A test case or leaf section did not run any assertions
+ NoAssertions = 0x01,
+ //! A command line test spec matched no test cases
+ UnmatchedTestSpec = 0x02,
+ }; };
- bool operator == (MessageInfo const& other) const {
- return sequence == other.sequence;
- }
- bool operator < (MessageInfo const& other) const {
- return sequence < other.sequence;
- }
- private:
- static unsigned int globalCount;
+ enum class ShowDurations {
+ DefaultForReporter,
+ Always,
+ Never
+ };
+ enum class TestRunOrder {
+ Declared,
+ LexicographicallySorted,
+ Randomized
};
+ enum class ColourMode : std::uint8_t {
+ //! Let Catch2 pick implementation based on platform detection
+ PlatformDefault,
+ //! Use ANSI colour code escapes
+ ANSI,
+ //! Use Win32 console colour API
+ Win32,
+ //! Don't use any colour
+ None
+ };
+ struct WaitForKeypress { enum When {
+ Never,
+ BeforeStart = 1,
+ BeforeExit = 2,
+ BeforeStartAndExit = BeforeStart | BeforeExit
+ }; };
-} // end namespace Catch
+ class TestSpec;
+ class IStream;
+
+ class IConfig : public Detail::NonCopyable {
+ public:
+ virtual ~IConfig();
+
+ virtual bool allowThrows() const = 0;
+ virtual StringRef name() const = 0;
+ virtual bool includeSuccessfulResults() const = 0;
+ virtual bool shouldDebugBreak() const = 0;
+ virtual bool warnAboutMissingAssertions() const = 0;
+ virtual bool warnAboutUnmatchedTestSpecs() const = 0;
+ virtual bool zeroTestsCountAsSuccess() const = 0;
+ virtual int abortAfter() const = 0;
+ virtual bool showInvisibles() const = 0;
+ virtual ShowDurations showDurations() const = 0;
+ virtual double minDuration() const = 0;
+ virtual TestSpec const& testSpec() const = 0;
+ virtual bool hasTestFilters() const = 0;
+ virtual std::vector<std::string> const& getTestsOrTags() const = 0;
+ virtual TestRunOrder runOrder() const = 0;
+ virtual uint32_t rngSeed() const = 0;
+ virtual unsigned int shardCount() const = 0;
+ virtual unsigned int shardIndex() const = 0;
+ virtual ColourMode defaultColourMode() const = 0;
+ virtual std::vector<std::string> const& getSectionsToRun() const = 0;
+ virtual Verbosity verbosity() const = 0;
+
+ virtual bool skipBenchmarks() const = 0;
+ virtual bool benchmarkNoAnalysis() const = 0;
+ virtual unsigned int benchmarkSamples() const = 0;
+ virtual double benchmarkConfidenceInterval() const = 0;
+ virtual unsigned int benchmarkResamples() const = 0;
+ virtual std::chrono::milliseconds benchmarkWarmupTime() const = 0;
+ };
+}
+
+#endif // CATCH_INTERFACES_CONFIG_HPP_INCLUDED
+
+
+#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
+#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
+
+
+#include <string>
+
+namespace Catch {
+
+ class TestCaseHandle;
+ struct TestCaseInfo;
+ class ITestCaseRegistry;
+ class IExceptionTranslatorRegistry;
+ class IExceptionTranslator;
+ class ReporterRegistry;
+ class IReporterFactory;
+ class ITagAliasRegistry;
+ class ITestInvoker;
+ class IMutableEnumValuesRegistry;
+ struct SourceLineInfo;
+
+ class StartupExceptionRegistry;
+ class EventListenerFactory;
+
+ using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
+
+ class IRegistryHub {
+ public:
+ virtual ~IRegistryHub(); // = default
+
+ virtual ReporterRegistry const& getReporterRegistry() const = 0;
+ virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
+ virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
+ virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0;
+
+
+ virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
+ };
+
+ class IMutableRegistryHub {
+ public:
+ virtual ~IMutableRegistryHub(); // = default
+ virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
+ virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0;
+ virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0;
+ virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0;
+ virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
+ virtual void re