diff options
| author | Martin Hořeňovský | 2022-07-17 20:18:44 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-07-17 20:18:44 +0200 |
| commit | 97c48e0c343d26d50764fafdc90b1e630fbd10ce (patch) | |
| tree | 2409658cbaf9d5a441ebe270836732aea5a6ffa2 | |
| parent | 9c9f35068edaa1290789c56f241fc54e7de0eeb0 (diff) | |
| download | catch3-3.1.0.tar.gz | |
v3.1.0v3.1.0
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | docs/cmake-integration.md | 2 | ||||
| -rw-r--r-- | docs/configuration.md | 2 | ||||
| -rw-r--r-- | docs/release-notes.md | 40 | ||||
| -rw-r--r-- | extras/catch_amalgamated.cpp | 1433 | ||||
| -rw-r--r-- | extras/catch_amalgamated.hpp | 126 | ||||
| -rw-r--r-- | src/catch2/catch_version.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/catch_version_macros.hpp | 4 |
8 files changed, 831 insertions, 780 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c0270559..7233477f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ endif() project(Catch2 - VERSION 3.0.1 # CML version placeholder, don't delete + VERSION 3.1.0 # CML version placeholder, don't delete LANGUAGES CXX # HOMEPAGE_URL is not supported until CMake version 3.12, which # we do not target yet. diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index 9637be9b..dc3efc9d 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -262,7 +262,7 @@ ParseAndAddCatchTests(bar) ### `CatchShardTests.cmake` -> `CatchShardTests.cmake` was introduced in Catch2 X.Y.Z. +> `CatchShardTests.cmake` was introduced in Catch2 3.1.0. `CatchShardTests.cmake` provides a function `catch_add_sharded_tests(TEST_BINARY)` that splits tests from `TEST_BINARY` diff --git a/docs/configuration.md b/docs/configuration.md index d857e792..9fd7f58b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -103,7 +103,7 @@ Catch2 will register a `JUnit` reporter writing to a path pointed by `XML_OUTPUT > `CATCH_CONFIG_BAZEL_SUPPORT` was [introduced](https://github.com/catchorg/Catch2/pull/2399) in Catch2 3.0.1. -> `CATCH_CONFIG_BAZEL_SUPPORT` was [deprecated](https://github.com/catchorg/Catch2/pull/2459) in Catch2 X.Y.Z. +> `CATCH_CONFIG_BAZEL_SUPPORT` was [deprecated](https://github.com/catchorg/Catch2/pull/2459) in Catch2 3.1.0. ## C++11 toggles diff --git a/docs/release-notes.md b/docs/release-notes.md index 3a5de276..da2c598c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ # Release notes **Contents**<br> +[3.1.0](#310)<br> [3.0.1](#301)<br> [2.13.7](#2137)<br> [2.13.6](#2136)<br> @@ -49,6 +50,45 @@ [Even Older versions](#even-older-versions)<br> +## 3.1.0 + +### Improvements +* Improved suppression of `-Wparentheses` for older GCCs + * Turns out that even GCC 9 does not properly handle `_Pragma`s in the C++ frontend. +* Added type constraints onto `random` generator (#2433) + * These constraints copy what the standard says for the underlying `std::uniform_int_distribution` +* Suppressed -Wunused-variable from nvcc (#2306, #2427) +* Suppressed -Wunused-variable from MinGW (#2132) +* Added All/Any/NoneTrue range matchers (#2319) + * These check that all/any/none of boolean values in a range are true. +* The JUnit reporter now normalizes classnames from C++ namespaces to Java-like namespaces (#2468) + * This provides better support for other JUnit based tools. +* The Bazel support now understands `BAZEL_TEST` environment variable (#2459) + * The `CATCH_CONFIG_BAZEL_SUPPORT` configuration option is also still supported. +* Returned support for compiling Catch2 with GCC 5 (#2448) + * This required removing inherited constructors from Catch2's internals. + * I recommend updating to a newer GCC anyway. +* `catch_discover_tests` now has a new options for setting library load path(s) when running the Catch2 binary (#2467) + + +### Fixes +* Fixed crash when listing listeners without any registered listeners (#2442) +* Fixed nvcc compilation error in constructor benchmarking helper (#2477) +* Catch2's CMakeList supports pre-3.12 CMake again (#2428) + * The gain from requiring CMake 3.12 was very minor, but y'all should really update to newer CMake + + +### Miscellaneous +* Fixed SelfTest build on MinGW (#2447) +* The in-repo conan recipe exports the CMake helper (#2460) +* Added experimental CMake script to showcase using test case sharding together with CTest + * Compared to `catch_discover_tests`, it supports very limited number of options and customization +* Added documentation page on best practices when running Catch2 tests +* Catch2 can be built as a dynamic library (#2397, #2398) + * Note that Catch2 does not have visibility annotations, and you are responsible for ensuring correct visibility built into the resulting library. + + + ## 3.0.1 **Catch2 now uses statically compiled library as its distribution model. diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index bd8c8119..ecda2301 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -5,8 +5,8 @@ // SPDX-License-Identifier: BSL-1.0 -// Catch v3.0.1 -// Generated: 2022-05-17 22:08:47.054486 +// Catch v3.1.0 +// Generated: 2022-07-17 20:14:05.885021 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -15,6 +15,51 @@ #include "catch_amalgamated.hpp" + + +namespace Catch { + namespace Benchmark { + namespace Detail { + ChronometerConcept::~ChronometerConcept() = default; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + + + + +namespace Catch { + namespace Benchmark { + namespace Detail { + BenchmarkFunction::callable::~callable() = default; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + + + +#include <exception> + +namespace Catch { + namespace Benchmark { + namespace Detail { + struct optimized_away_error : std::exception { + const char* what() const noexcept override; + }; + + const char* optimized_away_error::what() const noexcept { + return "could not measure benchmark, maybe it was optimized away"; + } + + void throw_optimized_away_error() { + Catch::throw_exception(optimized_away_error{}); + } + + } // namespace Detail + } // namespace Benchmark +} // namespace Catch + + // Adapted from donated nonius code. @@ -265,72 +310,6 @@ namespace Catch { } // namespace Catch -/** \file - * This is a special TU that combines what would otherwise be a very - * small benchmarking-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -//////////////////////////////////////////// -// vvv formerly catch_chronometer.cpp vvv // -//////////////////////////////////////////// - - -namespace Catch { - namespace Benchmark { - namespace Detail { - ChronometerConcept::~ChronometerConcept() = default; - } // namespace Detail - } // namespace Benchmark -} // namespace Catch - - -/////////////////////////////////////////////////// -// vvv formerly catch_benchmark_function.cpp vvv // -/////////////////////////////////////////////////// - - -namespace Catch { - namespace Benchmark { - namespace Detail { - BenchmarkFunction::callable::~callable() = default; - } // namespace Detail - } // namespace Benchmark -} // namespace Catch - - -///////////////////////////////////////////////// -// vvv formerly catch_run_for_at_least.cpp vvv // -///////////////////////////////////////////////// - -#include <exception> - -namespace Catch { - namespace Benchmark { - namespace Detail { - struct optimized_away_error : std::exception { - const char* what() const noexcept override; - }; - - const char* optimized_away_error::what() const noexcept { - return "could not measure benchmark, maybe it was optimized away"; - } - - void throw_optimized_away_error() { - Catch::throw_exception(optimized_away_error{}); - } - - } // namespace Detail - } // namespace Benchmark -} // namespace Catch - - #include <cmath> #include <limits> @@ -507,6 +486,28 @@ namespace Catch { +namespace { + bool provideBazelReporterOutput() { +#ifdef CATCH_CONFIG_BAZEL_SUPPORT + return true; +#else + +# if defined( _MSC_VER ) + // On Windows getenv throws a warning as there is no input validation, + // since the switch is hardcoded, this should not be an issue. +# pragma warning( push ) +# pragma warning( disable : 4996 ) +# endif + + return std::getenv( "BAZEL_TEST" ) != nullptr; + +# if defined( _MSC_VER ) +# pragma warning( pop ) +# endif +#endif + } +} + namespace Catch { bool operator==( ProcessedReporterSpec const& lhs, @@ -553,27 +554,27 @@ namespace Catch { } ); } -#if defined( CATCH_CONFIG_BAZEL_SUPPORT ) - // Register a JUnit reporter for Bazel. Bazel sets an environment - // variable with the path to XML output. If this file is written to - // during test, Bazel will not generate a default XML output. - // This allows the XML output file to contain higher level of detail - // than what is possible otherwise. + if(provideBazelReporterOutput()){ + // Register a JUnit reporter for Bazel. Bazel sets an environment + // variable with the path to XML output. If this file is written to + // during test, Bazel will not generate a default XML output. + // This allows the XML output file to contain higher level of detail + // than what is possible otherwise. # if defined( _MSC_VER ) - // On Windows getenv throws a warning as there is no input validation, - // since the key is hardcoded, this should not be an issue. -# pragma warning( push ) -# pragma warning( disable : 4996 ) + // On Windows getenv throws a warning as there is no input validation, + // since the key is hardcoded, this should not be an issue. +# pragma warning( push ) +# pragma warning( disable : 4996 ) # endif - const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" ); + const auto bazelOutputFilePtr = std::getenv( "XML_OUTPUT_FILE" ); # if defined( _MSC_VER ) # pragma warning( pop ) # endif - if ( bazelOutputFilePtr != nullptr ) { - m_data.reporterSpecifications.push_back( - { "junit", std::string( bazelOutputFilePtr ), {}, {} } ); - } -#endif + if ( bazelOutputFilePtr != nullptr ) { + m_data.reporterSpecifications.push_back( + { "junit", std::string( bazelOutputFilePtr ), {}, {} } ); + } + } // We now fixup the reporter specs to handle default output spec, @@ -1180,6 +1181,22 @@ namespace Catch { + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + CATCH_TRY { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } CATCH_CATCH_ALL { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} + + + #include <cassert> #include <cctype> #include <algorithm> @@ -1873,7 +1890,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 0, 1, "", 0 ); + static Version version( 3, 1, 0, "", 0 ); return version; } @@ -1882,27 +1899,6 @@ namespace Catch { - -std::uint32_t Catch::Generators::Detail::getSeed() { return sharedRng()(); } - - -/** \file - * This is a special TU that combines what would otherwise be a very - * small generator-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -//////////////////////////////////////////////////// -// vvv formerly catch_generator_exception.cpp vvv // -//////////////////////////////////////////////////// - - namespace Catch { const char* GeneratorException::what() const noexcept { @@ -1912,9 +1908,6 @@ namespace Catch { } // end namespace Catch -/////////////////////////////////////////// -// vvv formerly catch_generators.cpp vvv // -/////////////////////////////////////////// namespace Catch { @@ -1941,81 +1934,31 @@ namespace Detail { } // namespace Catch -/** \file - * This is a special TU that combines what would otherwise be a very - * small interfaces-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -/////////////////////////////////////////////////// -// vvv formerly catch_interfaces_capture.cpp vvv // -/////////////////////////////////////////////////// -namespace Catch { - IResultCapture::~IResultCapture() = default; -} - -////////////////////////////////////////////////// -// vvv formerly catch_interfaces_config.cpp vvv // -////////////////////////////////////////////////// - - -namespace Catch { - IConfig::~IConfig() = default; -} - - -///////////////////////////////////////////////////// -// vvv formerly catch_interfaces_exception.cpp vvv // -///////////////////////////////////////////////////// - - -namespace Catch { - IExceptionTranslator::~IExceptionTranslator() = default; - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; -} +std::uint32_t Catch::Generators::Detail::getSeed() { return sharedRng()(); } -//////////////////////////////////////////////////////// -// vvv formerly catch_interfaces_registry_hub.cpp vvv // -//////////////////////////////////////////////////////// namespace Catch { - IRegistryHub::~IRegistryHub() = default; - IMutableRegistryHub::~IMutableRegistryHub() = default; + IResultCapture::~IResultCapture() = default; } -//////////////////////////////////////////////////// -// vvv formerly catch_interfaces_testcase.cpp vvv // -//////////////////////////////////////////////////// namespace Catch { - ITestInvoker::~ITestInvoker() = default; - ITestCaseRegistry::~ITestCaseRegistry() = default; + IConfig::~IConfig() = default; } -namespace Catch { - IReporterRegistry::~IReporterRegistry() = default; -} - - namespace Catch { - IReporterFactory::~IReporterFactory() = default; - EventListenerFactory::~EventListenerFactory() = default; + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; } @@ -2046,6 +1989,14 @@ namespace Catch { + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} + + + #include <algorithm> #include <cassert> #include <iomanip> @@ -2134,6 +2085,29 @@ namespace Catch { + +namespace Catch { + IReporterFactory::~IReporterFactory() = default; + EventListenerFactory::~EventListenerFactory() = default; +} + + + + +namespace Catch { + IReporterRegistry::~IReporterRegistry() = default; +} + + + + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} + + + namespace Catch { AssertionHandler::AssertionHandler @@ -2672,221 +2646,6 @@ namespace Catch { } // namespace Catch -/** \file - * This is a special TU that combines what would otherwise be a very - * small top-level TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - - -//////////////////////////////////////////////////////// -// vvv formerly catch_tag_alias_autoregistrar.cpp vvv // -//////////////////////////////////////////////////////// - - -namespace Catch { - - RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { - CATCH_TRY { - getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); - } CATCH_CATCH_ALL { - // Do not throw when constructing global objects, instead register the exception to be processed later - getMutableRegistryHub().registerStartupException(); - } - } - -} - - -////////////////////////////////////////// -// vvv formerly catch_polyfills.cpp vvv // -////////////////////////////////////////// - -#include <cmath> - -namespace Catch { - -#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) - bool isnan(float f) { - return std::isnan(f); - } - bool isnan(double d) { - return std::isnan(d); - } -#else - // For now we only use this for embarcadero - bool isnan(float f) { - return std::_isnan(f); - } - bool isnan(double d) { - return std::_isnan(d); - } -#endif - -} // end namespace Catch - - -//////////////////////////////////////////////////// -// vvv formerly catch_uncaught_exceptions.cpp vvv // -//////////////////////////////////////////////////// - - -#include <exception> - -namespace Catch { - bool uncaught_exceptions() { -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) - return false; -#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) - return std::uncaught_exceptions() > 0; -#else - return std::uncaught_exception(); -#endif - } -} // end namespace Catch - - -//////////////////////////////////////////// -// vvv formerly catch_errno_guard.cpp vvv // -//////////////////////////////////////////// - -#include <cerrno> - -namespace Catch { - ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} - ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } -} - - -/////////////////////////////////////////// -// vvv formerly catch_decomposer.cpp vvv // -/////////////////////////////////////////// - -namespace Catch { - - ITransientExpression::~ITransientExpression() = default; - - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { - if( lhs.size() + rhs.size() < 40 && - lhs.find('\n') == std::string::npos && - rhs.find('\n') == std::string::npos ) - os << lhs << ' ' << op << ' ' << rhs; - else - os << lhs << '\n' << op << '\n' << rhs; - } -} - - -/////////////////////////////////////////////////////////// -// vvv formerly catch_startup_exception_registry.cpp vvv // -/////////////////////////////////////////////////////////// - -namespace Catch { -#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) - void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { - CATCH_TRY { - m_exceptions.push_back(exception); - } CATCH_CATCH_ALL { - // If we run out of memory during start-up there's really not a lot more we can do about it - std::terminate(); - } - } - - std::vector<std::exception_ptr> const& StartupExceptionRegistry::getExceptions() const noexcept { - return m_exceptions; - } -#endif - -} // end namespace Catch - - -////////////////////////////////////////////// -// vvv formerly catch_leak_detector.cpp vvv // -////////////////////////////////////////////// - - -#ifdef CATCH_CONFIG_WINDOWS_CRTDBG -#include <crtdbg.h> - -namespace Catch { - - LeakDetector::LeakDetector() { - int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - flag |= _CRTDBG_LEAK_CHECK_DF; - flag |= _CRTDBG_ALLOC_MEM_DF; - _CrtSetDbgFlag(flag); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - // Change this to leaking allocation's number to break there - _CrtSetBreakAlloc(-1); - } -} - -#else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv - - Catch::LeakDetector::LeakDetector() {} - -#endif // CATCH_CONFIG_WINDOWS_CRTDBG - -Catch::LeakDetector::~LeakDetector() { - Catch::cleanUp(); -} - - -///////////////////////////////////////////// -// vvv formerly catch_message_info.cpp vvv // -///////////////////////////////////////////// - - -namespace Catch { - - MessageInfo::MessageInfo( StringRef _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - -} // end namespace Catch - - - - -////////////////////////////////////////// -// vvv formerly catch_lazy_expr.cpp vvv // -////////////////////////////////////////// - -namespace Catch { - - auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { - if (lazyExpr.m_isNegated) - os << '!'; - - if (lazyExpr) { - if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) - os << '(' << *lazyExpr.m_transientExpression << ')'; - else - os << *lazyExpr.m_transientExpression; - } else { - os << "{** error - unchecked empty expression requested **}"; - } - return os; - } - -} // namespace Catch - - #include <fstream> @@ -3425,25 +3184,22 @@ namespace Catch { Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode implSelection, IStream* stream ) { - if ( implSelection == ColourMode::None ) { - return Detail::make_unique<NoColourImpl>( stream ); - } - if ( implSelection == ColourMode::ANSI ) { - return Detail::make_unique<ANSIColourImpl>( stream ); - } #if defined( CATCH_CONFIG_COLOUR_WIN32 ) if ( implSelection == ColourMode::Win32 ) { return Detail::make_unique<Win32ColourImpl>( stream ); } #endif + if ( implSelection == ColourMode::ANSI ) { + return Detail::make_unique<ANSIColourImpl>( stream ); + } + if ( implSelection == ColourMode::None ) { + return Detail::make_unique<NoColourImpl>( stream ); + } - // todo: check win32 eligibility under ifdef, otherwise ansi if ( implSelection == ColourMode::PlatformDefault) { -#if defined (CATCH_CONFIG_COLOUR_WIN32) +#if defined( CATCH_CONFIG_COLOUR_WIN32 ) if ( Win32ColourImpl::useImplementationForStream( *stream ) ) { return Detail::make_unique<Win32ColourImpl>( stream ); - } else { - return Detail::make_unique<NoColourImpl>( stream ); } #endif if ( ANSIColourImpl::useImplementationForStream( *stream ) ) { @@ -3679,6 +3435,23 @@ namespace Catch { + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << ' ' << op << ' ' << rhs; + else + os << lhs << '\n' << op << '\n' << rhs; + } +} + + + #include <stdexcept> @@ -3779,6 +3552,16 @@ namespace Catch { + +#include <cerrno> + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} + + + namespace Catch { ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { @@ -4256,6 +4039,58 @@ namespace Detail { +namespace Catch { + + auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { + if (lazyExpr.m_isNegated) + os << '!'; + + if (lazyExpr) { + if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) + os << '(' << *lazyExpr.m_transientExpression << ')'; + else + os << *lazyExpr.m_transientExpression; + } else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + +} // namespace Catch + + + + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include <crtdbg.h> + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv + + Catch::LeakDetector::LeakDetector() {} + +#endif // CATCH_CONFIG_WINDOWS_CRTDBG + +Catch::LeakDetector::~LeakDetector() { + Catch::cleanUp(); +} + + + + namespace Catch { namespace { @@ -4390,6 +4225,25 @@ int main (int argc, char * argv[]) { + +namespace Catch { + + MessageInfo::MessageInfo( StringRef _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + +} // end namespace Catch + + + #include <cstdio> #include <cstring> #include <sstream> @@ -4528,6 +4382,32 @@ namespace Catch { + +#include <cmath> + +namespace Catch { + +#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) + bool isnan(float f) { + return std::isnan(f); + } + bool isnan(double d) { + return std::isnan(d); + } +#else + // For now we only use this for embarcadero + bool isnan(float f) { + return std::_isnan(f); + } + bool isnan(double d) { + return std::_isnan(d); + } +#endif + +} // end namespace Catch + + + namespace Catch { namespace { @@ -4784,7 +4664,7 @@ namespace Catch { return {}; } - auto ret = kvPairs.emplace( kv.key, kv.value ); + auto ret = kvPairs.emplace( std::string(kv.key), std::string(kv.value) ); if ( !ret.second ) { // Duplicated key. We might want to handle this differently, // e.g. by overwriting the existing value? @@ -5387,6 +5267,11 @@ namespace Catch { // before running the tests themselves, or the binary can crash // without failed test being reported. FatalConditionHandlerGuard _(&m_fatalConditionhandler); + // We keep having issue where some compilers warn about an unused + // variable, even though the type has non-trivial constructor and + // destructor. This is annoying and ugly, but it makes them stfu. + (void)_; + m_activeTestCase->invoke(); } @@ -5618,6 +5503,27 @@ namespace Catch { +namespace Catch { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + CATCH_TRY { + m_exceptions.push_back(exception); + } CATCH_CATCH_ALL { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector<std::exception_ptr> const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } +#endif + +} // end namespace Catch + + + + #include <iostream> @@ -6792,6 +6698,23 @@ namespace Catch { + +#include <exception> + +namespace Catch { + bool uncaught_exceptions() { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return false; +#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif + } +} // end namespace Catch + + + namespace Catch { WildcardPattern::WildcardPattern( std::string const& pattern, @@ -7171,6 +7094,72 @@ namespace { + + +namespace Catch { +namespace Matchers { + + std::string MatcherUntypedBase::toString() const { + if (m_cachedToString.empty()) { + m_cachedToString = describe(); + } + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + +} // namespace Matchers +} // namespace Catch + + + + +namespace Catch { +namespace Matchers { + + std::string IsEmptyMatcher::describe() const { + return "is empty"; + } + + std::string HasSizeMatcher::describe() const { + ReusableStringStream sstr; + sstr << "has size == " << m_target_size; + return sstr.str(); + } + + IsEmptyMatcher IsEmpty() { + return {}; + } + + HasSizeMatcher SizeIs(std::size_t sz) { + return HasSizeMatcher{ sz }; + } + +} // end namespace Matchers + |