From 88d8369751da00ea590b124c01dcb21ea41b65c2 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 5 Jun 2026 20:34:20 -0700 Subject: [PATCH] [upstream_utils] Update catch2 to 3.15.0 (#8955) --- .../catch2/benchmark/detail/catch_analyse.cpp | 10 +- .../detail/catch_run_for_at_least.cpp | 2 +- .../main/native/cpp/catch2/catch_message.cpp | 12 +-- .../native/cpp/catch2/catch_registry_hub.cpp | 5 - .../main/native/cpp/catch2/catch_session.cpp | 1 + .../main/native/cpp/catch2/catch_version.cpp | 2 +- .../internal/catch_assertion_handler.cpp | 9 +- ...alues_registry.cpp => catch_enum_info.cpp} | 28 ++---- .../catch2/internal/catch_output_redirect.cpp | 6 +- .../cpp/catch2/internal/catch_run_context.cpp | 55 +++++------ .../internal/catch_tag_alias_registry.cpp | 7 +- .../internal/catch_test_failure_exception.cpp | 4 +- .../cpp/catch2/matchers/catch_matchers.cpp | 10 +- .../catch_matchers_container_properties.cpp | 8 -- .../matchers/catch_matchers_quantifiers.cpp | 6 +- .../matchers/catch_matchers_templated.cpp | 6 +- .../catch_reporter_cumulative_base.cpp | 5 +- .../reporters/catch_reporter_helpers.cpp | 4 +- .../detail/catch_benchmark_function.hpp | 2 +- .../main/native/include/catch2/catch_all.hpp | 2 +- .../native/include/catch2/catch_message.hpp | 18 +++- .../native/include/catch2/catch_tostring.hpp | 34 ++++--- .../catch2/catch_translate_exception.hpp | 2 +- .../include/catch2/catch_version_macros.hpp | 2 +- .../interfaces/catch_interfaces_all.hpp | 1 - .../interfaces/catch_interfaces_capture.hpp | 10 -- .../interfaces/catch_interfaces_config.hpp | 2 +- .../catch_interfaces_enum_values_registry.hpp | 47 --------- .../catch_interfaces_registry_hub.hpp | 1 - .../internal/catch_assertion_handler.hpp | 16 ++- .../internal/catch_compiler_capabilities.hpp | 24 +++-- .../catch2/internal/catch_decomposer.hpp | 4 +- .../catch2/internal/catch_enum_info.hpp | 48 +++++++++ .../internal/catch_enum_values_registry.hpp | 36 ------- .../catch_exception_translator_registry.hpp | 2 +- .../catch2/internal/catch_run_context.hpp | 4 +- .../catch2/internal/catch_singletons.hpp | 2 +- .../internal/catch_tag_alias_registry.hpp | 2 +- .../catch_test_case_registry_impl.hpp | 2 +- .../catch2/internal/catch_test_macro_impl.hpp | 12 ++- .../catch2/internal/catch_test_registry.hpp | 6 +- .../catch2/matchers/catch_matchers.hpp | 44 +++++++-- .../catch_matchers_container_properties.hpp | 18 ++-- .../matchers/catch_matchers_contains.hpp | 14 +-- .../matchers/catch_matchers_quantifiers.hpp | 45 +++++---- .../matchers/catch_matchers_templated.hpp | 99 ++++++++++++------- .../matchers/internal/catch_matchers_impl.hpp | 2 +- upstream_utils/catch2.py | 2 +- 48 files changed, 363 insertions(+), 320 deletions(-) rename thirdparty/catch2/src/main/native/cpp/catch2/internal/{catch_enum_values_registry.cpp => catch_enum_info.cpp} (65%) delete mode 100644 thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_enum_values_registry.hpp create mode 100644 thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_info.hpp delete mode 100644 thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_values_registry.hpp diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_analyse.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_analyse.cpp index 14d7f4506d..8934f84fe9 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_analyse.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_analyse.cpp @@ -36,11 +36,11 @@ namespace Catch { samples.data(), samples.data() + samples.size() ); auto wrap_estimate = [](Estimate e) { - return Estimate { - FDuration(e.point), - FDuration(e.lower_bound), - FDuration(e.upper_bound), - e.confidence_interval, + return Estimate{ + FDuration( e.point ), + FDuration( e.lower_bound ), + FDuration( e.upper_bound ), + e.confidence_interval, }; }; std::vector samples2; diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_run_for_at_least.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_run_for_at_least.cpp index 3ebdcc05ad..8299914968 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_run_for_at_least.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/benchmark/detail/catch_run_for_at_least.cpp @@ -14,7 +14,7 @@ namespace Catch { namespace Benchmark { namespace Detail { - struct optimized_away_error : std::exception { + struct optimized_away_error final : std::exception { const char* what() const noexcept override; }; diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/catch_message.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/catch_message.cpp index 870651e382..3a83e34e8b 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/catch_message.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/catch_message.cpp @@ -5,8 +5,8 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 + #include -#include #include #include @@ -22,7 +22,7 @@ namespace Catch { m_messageId( builder.m_info.sequence ) { MessageInfo info( CATCH_MOVE( builder.m_info ) ); info.message = builder.m_stream.str(); - IResultCapture::pushScopedMessage( CATCH_MOVE( info ) ); + Detail::pushScopedMessage( CATCH_MOVE( info ) ); } ScopedMessage::ScopedMessage( ScopedMessage&& old ) noexcept: @@ -31,7 +31,7 @@ namespace Catch { } ScopedMessage::~ScopedMessage() { - if ( !m_moved ) { IResultCapture::popScopedMessage( m_messageId ); } + if ( !m_moved ) { Detail::popScopedMessage( m_messageId ); } } @@ -103,7 +103,7 @@ namespace Catch { assert( m_captured == m_messages.size() ); if ( m_isScoped ) { for ( auto const& message : m_messages ) { - IResultCapture::popScopedMessage( message.sequence ); + Detail::popScopedMessage( message.sequence ); } } } @@ -112,9 +112,9 @@ namespace Catch { assert( index < m_messages.size() ); m_messages[index].message += value; if ( m_isScoped ) { - IResultCapture::pushScopedMessage( CATCH_MOVE( m_messages[index] ) ); + Detail::pushScopedMessage( CATCH_MOVE( m_messages[index] ) ); } else { - IResultCapture::addUnscopedMessage( CATCH_MOVE( m_messages[index] ) ); + Detail::addUnscopedMessage( CATCH_MOVE( m_messages[index] ) ); } m_captured++; } diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/catch_registry_hub.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/catch_registry_hub.cpp index 925468faa1..25aecdde71 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/catch_registry_hub.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/catch_registry_hub.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -72,9 +71,6 @@ namespace Catch { CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!"); #endif } - IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override { - return m_enumValuesRegistry; - } private: TestRegistry m_testCaseRegistry; @@ -82,7 +78,6 @@ namespace Catch { ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; TagAliasRegistry m_tagAliasRegistry; StartupExceptionRegistry m_exceptionRegistry; - Detail::EnumValuesRegistry m_enumValuesRegistry; }; } diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/catch_session.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/catch_session.cpp index 042b7f4d3a..0487fe7522 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/catch_session.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/catch_session.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/catch_version.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/catch_version.cpp index 403db2ebc6..eb385fe291 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/catch_version.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/catch_version.cpp @@ -36,7 +36,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 14, 0, "", 0 ); + static Version version( 3, 15, 0, "", 0 ); return version; } diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_assertion_handler.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_assertion_handler.cpp index 9a28e79c21..79d5dcd853 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_assertion_handler.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_assertion_handler.cpp @@ -6,21 +6,28 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include #include +#include #include #include +#include #include #include namespace Catch { + void AssertionHandler::finishIncomplete() { + m_resultCapture.handleIncomplete( m_assertionInfo ); + } + AssertionHandler::AssertionHandler ( StringRef macroName, SourceLineInfo const& lineInfo, StringRef capturedExpression, ResultDisposition::Flags resultDisposition ) : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, - m_resultCapture( getResultCapture() ) + m_resultCapture( static_cast(getResultCapture()) ) { m_resultCapture.notifyAssertionStarted( m_assertionInfo ); } diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_values_registry.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_info.cpp similarity index 65% rename from thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_values_registry.cpp rename to thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_info.cpp index a94b60881e..0793abd9ec 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_values_registry.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_enum_info.cpp @@ -5,15 +5,14 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#include + +#include #include #include namespace Catch { - IMutableEnumValuesRegistry::~IMutableEnumValuesRegistry() = default; - namespace Detail { namespace { @@ -39,9 +38,7 @@ namespace Catch { return parsed; } - EnumInfo::~EnumInfo() = default; - - StringRef EnumInfo::lookup( int value ) const { + StringRef EnumInfo::lookup( int64_t value ) const { for( auto const& valueToName : m_values ) { if( valueToName.first == value ) return valueToName.second; @@ -49,25 +46,20 @@ namespace Catch { return "{** unexpected enum value **}"_sr; } - Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ) { - auto enumInfo = Catch::Detail::make_unique(); - enumInfo->m_name = enumName; - enumInfo->m_values.reserve( values.size() ); + EnumInfo makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ) { + EnumInfo enumInfo; + enumInfo.m_name = enumName; + enumInfo.m_values.reserve( values.size() ); const auto valueNames = Catch::Detail::parseEnums( allValueNames ); assert( valueNames.size() == values.size() ); - std::size_t i = 0; - for( auto value : values ) - enumInfo->m_values.emplace_back(value, valueNames[i++]); + for (size_t i = 0; i < values.size(); ++i) { + enumInfo.m_values.emplace_back( values[i], valueNames[i] ); + } return enumInfo; } - EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values ) { - m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); - return *m_enumInfos.back(); - } - } // Detail } // Catch diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_output_redirect.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_output_redirect.cpp index 245e1376cf..0ea126a5bb 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_output_redirect.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_output_redirect.cpp @@ -33,7 +33,7 @@ namespace Catch { namespace { //! A no-op implementation, used if no reporter wants output //! redirection. - class NoopRedirect : public OutputRedirect { + class NoopRedirect final : public OutputRedirect { void activateImpl() override {} void deactivateImpl() override {} std::string getStdout() override { return {}; } @@ -70,7 +70,7 @@ namespace Catch { * Redirects the `std::cout`, `std::cerr`, `std::clog` streams, * but does not touch the actual `stdout`/`stderr` file descriptors. */ - class StreamRedirect : public OutputRedirect { + class StreamRedirect final : public OutputRedirect { ReusableStringStream m_redirectedOut, m_redirectedErr; RedirectedStreamNew m_cout, m_cerr, m_clog; @@ -181,7 +181,7 @@ namespace Catch { * Works by replacing the file descriptors numbered 1 and 2 * with an open temporary file. */ - class FileRedirect : public OutputRedirect { + class FileRedirect final : public OutputRedirect { TempFile m_outFile, m_errFile; int m_originalOut = -1; int m_originalErr = -1; diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_run_context.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_run_context.cpp index fd4b7a3846..a435170f41 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_run_context.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_run_context.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -308,6 +309,25 @@ namespace Catch { } CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + + void pushScopedMessage( MessageInfo&& message ) { + Detail::g_messageHolder().addScopedMessage( CATCH_MOVE( message ) ); + } + + void popScopedMessage( unsigned int messageId ) { + Detail::g_messageHolder().removeMessage( messageId ); + } + + void emplaceUnscopedMessage( MessageBuilder&& builder ) { + Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( builder ) ); + } + + void addUnscopedMessage( MessageInfo&& message ) { + Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( message ) ); + } + + bool lastAssertionPassed() { return Detail::g_lastAssertionPassed; } + } // namespace Detail RunContext::RunContext(IConfig const* _config, IEventListenerPtr&& reporter) @@ -441,14 +461,13 @@ namespace Catch { Detail::g_lastAssertionPassed = true; } else if (!result.succeeded()) { Detail::g_lastAssertionPassed = false; - if (result.isOk()) { - } - else if( m_activeTestCase->getTestCaseInfo().okToFail() ) // Read from a shared state established before the threads could start, this is fine + if (result.isOk()) {} + else if( m_activeTestCase->getTestCaseInfo().okToFail() ) { // Read from a shared state established before the threads could start, this is fine m_atomicAssertionCount.failedButOk++; - else + } else { m_atomicAssertionCount.failed++; - } - else { + } + } else { Detail::g_lastAssertionPassed = true; } @@ -630,7 +649,7 @@ namespace Catch { // and since IResultCapture::getLastResult is deprecated, // we will leave it as is, until it is finally removed. Detail::LockGuard _( m_assertionMutex ); - return &(*m_lastResult); + return &*m_lastResult; } void RunContext::exceptionEarlyReported() { @@ -704,10 +723,6 @@ namespace Catch { m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); } - bool RunContext::lastAssertionPassed() { - return Detail::g_lastAssertionPassed; - } - void RunContext::assertionPassedFastPath(SourceLineInfo lineInfo) { // We want to save the line info for better experience with unexpected assertions Detail::g_lastKnownLineInfo = lineInfo; @@ -886,7 +901,7 @@ namespace Catch { } void RunContext::populateReaction( AssertionReaction& reaction, - bool has_normal_disposition ) { + bool has_normal_disposition ) const { reaction.shouldDebugBreak = m_shouldDebugBreak; reaction.shouldThrow = aborting() || has_normal_disposition; } @@ -937,22 +952,6 @@ namespace Catch { } } - void IResultCapture::pushScopedMessage( MessageInfo&& message ) { - Detail::g_messageHolder().addScopedMessage( CATCH_MOVE( message ) ); - } - - void IResultCapture::popScopedMessage( unsigned int messageId ) { - Detail::g_messageHolder().removeMessage( messageId ); - } - - void IResultCapture::emplaceUnscopedMessage( MessageBuilder&& builder ) { - Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( builder ) ); - } - - void IResultCapture::addUnscopedMessage( MessageInfo&& message ) { - Detail::g_messageHolder().addUnscopedMessage( CATCH_MOVE( message ) ); - } - void seedRng(IConfig const& config) { sharedRng().seed(config.rngSeed()); } diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_tag_alias_registry.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_tag_alias_registry.cpp index 510df167f9..e87e405069 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_tag_alias_registry.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_tag_alias_registry.cpp @@ -16,10 +16,11 @@ namespace Catch { TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { auto it = m_registry.find( alias ); - if( it != m_registry.end() ) - return &(it->second); - else + if ( it != m_registry.end() ) { + return &it->second; + } else { return nullptr; + } } std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_test_failure_exception.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_test_failure_exception.cpp index 8ea3131313..8c34278ff5 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_test_failure_exception.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/internal/catch_test_failure_exception.cpp @@ -14,7 +14,7 @@ namespace Catch { void throw_test_failure_exception() { #if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) - throw TestFailureException{}; + throw TestFailureException{}; //NOLINT(bugprone-std-exception-baseclass) #else CATCH_ERROR( "Test failure requires aborting test!" ); #endif @@ -22,7 +22,7 @@ namespace Catch { void throw_test_skip_exception() { #if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) - throw Catch::TestSkipException(); + throw Catch::TestSkipException(); //NOLINT(bugprone-std-exception-baseclass) #else CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); #endif diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers.cpp index 123b30413d..d1add581c8 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers.cpp @@ -13,13 +13,13 @@ namespace Catch { namespace Matchers { std::string MatcherUntypedBase::toString() const { - if (m_cachedToString.empty()) { - m_cachedToString = describe(); - } - return m_cachedToString; + return describe(); } - MatcherUntypedBase::~MatcherUntypedBase() = default; + std::string MatcherUntypedBase::describe() const { + using namespace std::string_literals; + return "Undescribed matcher"s; + } } // namespace Matchers } // namespace Catch diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_container_properties.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_container_properties.cpp index f0c535bcbf..6297221e33 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_container_properties.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_container_properties.cpp @@ -22,13 +22,5 @@ namespace Matchers { return sstr.str(); } - IsEmptyMatcher IsEmpty() { - return {}; - } - - HasSizeMatcher SizeIs(std::size_t sz) { - return HasSizeMatcher{ sz }; - } - } // end namespace Matchers } // end namespace Catch diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_quantifiers.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_quantifiers.cpp index 5a7524672b..aeb1cc405b 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_quantifiers.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_quantifiers.cpp @@ -9,16 +9,12 @@ namespace Catch { namespace Matchers { - std::string AllTrueMatcher::describe() const { return "contains only true"; } - AllTrueMatcher AllTrue() { return AllTrueMatcher{}; } + std::string AllTrueMatcher::describe() const { return "contains only true"; } std::string NoneTrueMatcher::describe() const { return "contains no true"; } - NoneTrueMatcher NoneTrue() { return NoneTrueMatcher{}; } - std::string AnyTrueMatcher::describe() const { return "contains at least one true"; } - AnyTrueMatcher AnyTrue() { return AnyTrueMatcher{}; } } // namespace Matchers } // namespace Catch diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_templated.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_templated.cpp index 2fc529d2b9..e755b479d1 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_templated.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/matchers/catch_matchers_templated.cpp @@ -9,7 +9,11 @@ namespace Catch { namespace Matchers { - MatcherGenericBase::~MatcherGenericBase() = default; + + std::string MatcherGenericBase::describe() const { + using namespace std::string_literals; + return "Undescribed generic matcher"s; + } namespace Detail { diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_cumulative_base.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_cumulative_base.cpp index 09169632b4..dc5ae4b052 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -20,9 +20,8 @@ namespace Catch { bool operator()( Detail::unique_ptr const& node ) const { - return ( - ( node->stats.sectionInfo.name == m_other.name ) && - ( node->stats.sectionInfo.lineInfo == m_other.lineInfo ) ); + return node->stats.sectionInfo.name == m_other.name + && node->stats.sectionInfo.lineInfo == m_other.lineInfo; } void operator=( BySectionInfo const& ) = delete; diff --git a/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_helpers.cpp b/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_helpers.cpp index 6fa68a3c2a..0044efb5de 100644 --- a/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_helpers.cpp +++ b/thirdparty/catch2/src/main/native/cpp/catch2/reporters/catch_reporter_helpers.cpp @@ -199,7 +199,7 @@ namespace Catch { } // minimum whitespace to pad tag counts, possibly overwritten below - size_t maxTagCountLen = 2; + int maxTagCountLen = 2; // determine necessary padding for tag count column if ( ! tags.empty() ) { @@ -214,7 +214,7 @@ namespace Catch { // more padding necessary for 3+ digits if (maxTagCount >= 100) { auto numDigits = 1 + std::floor( std::log10( maxTagCount ) ); - maxTagCountLen = static_cast( numDigits ); + maxTagCountLen = static_cast( numDigits ); } } diff --git a/thirdparty/catch2/src/main/native/include/catch2/benchmark/detail/catch_benchmark_function.hpp b/thirdparty/catch2/src/main/native/include/catch2/benchmark/detail/catch_benchmark_function.hpp index 90b07b76e9..1f9ae9fb11 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -41,7 +41,7 @@ namespace Catch { callable& operator=(callable&&) = default; }; template - struct model : public callable { + struct model final : public callable { model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {} model(Fun const& fun_) : fun(fun_) {} diff --git a/thirdparty/catch2/src/main/native/include/catch2/catch_all.hpp b/thirdparty/catch2/src/main/native/include/catch2/catch_all.hpp index 97226dd115..82b1140590 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/catch_all.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/catch_all.hpp @@ -68,7 +68,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/thirdparty/catch2/src/main/native/include/catch2/catch_message.hpp b/thirdparty/catch2/src/main/native/include/catch2/catch_message.hpp index 9e868516a2..4582654fae 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/catch_message.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/catch_message.hpp @@ -13,16 +13,28 @@ #include #include #include +#include #include -#include #include #include namespace Catch { + struct MessageInfo; + struct MessageBuilder; + + namespace Detail { + // The message state affecting functions have to be defined in + // the TU where the thread-local message holders are defined. + // Currently this is catch_run_context.cpp + + void pushScopedMessage( MessageInfo&& message ); + void popScopedMessage( unsigned int messageId ); + void addUnscopedMessage( MessageInfo&& message ); + void emplaceUnscopedMessage( MessageBuilder&& builder ); + } // namespace Detail struct SourceLineInfo; - class IResultCapture; struct MessageStream { @@ -112,7 +124,7 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \ - Catch::IResultCapture::emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) + Catch::Detail::emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) #if defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) diff --git a/thirdparty/catch2/src/main/native/include/catch2/catch_tostring.hpp b/thirdparty/catch2/src/main/native/include/catch2/catch_tostring.hpp index b005212f83..e421b8b550 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/catch_tostring.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/catch_tostring.hpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #ifdef CATCH_CONFIG_CPP17_STRING_VIEW #include @@ -383,7 +384,10 @@ namespace Catch { } #endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER -#if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL) +#if defined( CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER ) && \ + defined( CATCH_CONFIG_CPP17_OPTIONAL ) && \ + /* P3168 turned optional into a range, making this ambigous with the range support */ \ + !defined( __cpp_lib_optional_range_support ) #include namespace Catch { template @@ -630,17 +634,21 @@ struct ratio_string { }; } -#include - -#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \ -namespace Catch { \ - template<> struct StringMaker { \ - static std::string convert( enumName value ) { \ - static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \ - return static_cast(enumInfo.lookup( static_cast( value ) )); \ - } \ - }; \ -} +#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \ + namespace Catch { \ + template <> \ + struct StringMaker { \ + static std::string convert( enumName value ) { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + static const auto enumInfo = ::Catch::Detail::makeEnumInfo( \ + #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + return static_cast( \ + enumInfo.lookup( static_cast( value ) ) ); \ + } \ + }; \ + } #define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ ) diff --git a/thirdparty/catch2/src/main/native/include/catch2/catch_translate_exception.hpp b/thirdparty/catch2/src/main/native/include/catch2/catch_translate_exception.hpp index 4d3bac6539..a1f3faa5b8 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/catch_translate_exception.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/catch_translate_exception.hpp @@ -22,7 +22,7 @@ namespace Catch { class ExceptionTranslatorRegistrar { template - class ExceptionTranslator : public IExceptionTranslator { + class ExceptionTranslator final : public IExceptionTranslator { public: constexpr ExceptionTranslator( std::string(*translateFunction)( T const& ) ) diff --git a/thirdparty/catch2/src/main/native/include/catch2/catch_version_macros.hpp b/thirdparty/catch2/src/main/native/include/catch2/catch_version_macros.hpp index 4b288c603d..41fc51aff7 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/catch_version_macros.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/catch_version_macros.hpp @@ -9,7 +9,7 @@ #define CATCH_VERSION_MACROS_HPP_INCLUDED #define CATCH_VERSION_MAJOR 3 -#define CATCH_VERSION_MINOR 14 +#define CATCH_VERSION_MINOR 15 #define CATCH_VERSION_PATCH 0 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED diff --git a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_all.hpp b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_all.hpp index a99fdcdc91..87eb259bfa 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_all.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_all.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_capture.hpp b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_capture.hpp index 79062cade8..4484e864d1 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_capture.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_capture.hpp @@ -22,8 +22,6 @@ namespace Catch { struct AssertionInfo; struct SectionInfo; struct SectionEndInfo; - struct MessageInfo; - struct MessageBuilder; struct Counts; struct AssertionReaction; struct SourceLineInfo; @@ -63,11 +61,6 @@ namespace Catch { virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; virtual void benchmarkFailed( StringRef error ) = 0; - static void pushScopedMessage( MessageInfo&& message ); - static void popScopedMessage( unsigned int messageId ); - static void addUnscopedMessage( MessageInfo&& message ); - static void emplaceUnscopedMessage( MessageBuilder&& builder ); - virtual void handleFatalErrorCondition( StringRef message ) = 0; virtual void handleExpr @@ -93,9 +86,6 @@ namespace Catch { ResultWas::OfType resultType, AssertionReaction &reaction ) = 0; - - virtual bool lastAssertionPassed() = 0; - // Deprecated, do not use: virtual std::string getCurrentTestName() const = 0; virtual const AssertionResult* getLastResult() const = 0; diff --git a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_config.hpp b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_config.hpp index 139d2c1e34..f52315db2e 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_config.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_config.hpp @@ -64,7 +64,7 @@ namespace Catch { class IStream; struct PathFilter; - class IConfig : public Detail::NonCopyable { + class IConfig : Detail::NonCopyable { public: virtual ~IConfig(); diff --git a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_enum_values_registry.hpp b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_enum_values_registry.hpp deleted file mode 100644 index 38b052d906..0000000000 --- a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_enum_values_registry.hpp +++ /dev/null @@ -1,47 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED -#define CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED - -#include - -#include - -namespace Catch { - - namespace Detail { - struct EnumInfo { - StringRef m_name; - std::vector> m_values; - - ~EnumInfo(); - - StringRef lookup( int value ) const; - }; - } // namespace Detail - - class IMutableEnumValuesRegistry { - public: - virtual ~IMutableEnumValuesRegistry(); // = default; - - virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values ) = 0; - - template - Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list values ) { - static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int"); - std::vector intValues; - intValues.reserve( values.size() ); - for( auto enumValue : values ) - intValues.push_back( static_cast( enumValue ) ); - return registerEnum( enumName, allEnums, intValues ); - } - }; - -} // Catch - -#endif // CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED diff --git a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_registry_hub.hpp b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_registry_hub.hpp index 113f223e80..3695a19265 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_registry_hub.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/interfaces/catch_interfaces_registry_hub.hpp @@ -53,7 +53,6 @@ namespace Catch { virtual void registerTranslator( Detail::unique_ptr&& translator ) = 0; virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; virtual void registerStartupException() noexcept = 0; - virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0; }; IRegistryHub const& getRegistryHub(); diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_assertion_handler.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_assertion_handler.hpp index c71c6898fd..93a70b1a89 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_assertion_handler.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_assertion_handler.hpp @@ -10,12 +10,13 @@ #include #include -#include #include namespace Catch { + class RunContext; + struct AssertionReaction { bool shouldDebugBreak = false; bool shouldThrow = false; @@ -26,7 +27,12 @@ namespace Catch { AssertionInfo m_assertionInfo; AssertionReaction m_reaction; bool m_completed = false; - IResultCapture& m_resultCapture; + // Since all uses are hidden in the .cpp file, we can directly use + // the final type and avoid going through virtual dispatch, without + // massive compilation time overhead. + RunContext& m_resultCapture; + + void finishIncomplete(); public: AssertionHandler @@ -35,9 +41,9 @@ namespace Catch { StringRef capturedExpression, ResultDisposition::Flags resultDisposition ); ~AssertionHandler() { - if ( !m_completed ) { - m_resultCapture.handleIncomplete( m_assertionInfo ); - } + // We want the common fast path inlinable, and the virtual + // dispatch in a function in single TU. + if ( !m_completed ) { finishIncomplete(); } } diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_compiler_capabilities.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_compiler_capabilities.hpp index 2bbee6bc61..2d6d0c7516 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_compiler_capabilities.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_compiler_capabilities.hpp @@ -27,16 +27,24 @@ #include #include -#ifdef __cplusplus +#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +#endif -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) -# define CATCH_CPP20_OR_GREATER -# endif +#if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) +# define CATCH_CPP20_OR_GREATER +#endif +// Matchers are only constexpr-able in C++20 +#if defined( CATCH_CPP20_OR_GREATER ) && \ + defined( __cpp_constexpr_dynamic_alloc ) && \ + __cpp_constexpr_dynamic_alloc >= 201907L && \ + /* GCC < 13 define the feature macro, but compiler bugs stop us from using it */ \ + ( !defined( __GNUC__ ) || __GNUC__ >= 13 || defined(__clang__) ) +# define CATCH_INTERNAL_CONSTEXPR_MATCHERS_ENABLED +# define CATCH_DESTRUCTOR_CONSTEXPR constexpr +#else +# define CATCH_DESTRUCTOR_CONSTEXPR #endif // Only GCC compiler should be used in this block, so other compilers trying to diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_decomposer.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_decomposer.hpp index fcc017dda9..ff628482e0 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_decomposer.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_decomposer.hpp @@ -193,7 +193,7 @@ namespace Catch { void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); template - class BinaryExpr : public ITransientExpression { + class BinaryExpr final : public ITransientExpression { LhsT m_lhs; StringRef m_op; RhsT m_rhs; @@ -269,7 +269,7 @@ namespace Catch { }; template - class UnaryExpr : public ITransientExpression { + class UnaryExpr final : public ITransientExpression { LhsT m_lhs; void streamReconstructedExpression( std::ostream &os ) const override { diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_info.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_info.hpp new file mode 100644 index 0000000000..b3036a821e --- /dev/null +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_info.hpp @@ -0,0 +1,48 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_ENUM_INFO_HPP_INCLUDED +#define CATCH_ENUM_INFO_HPP_INCLUDED + +#include + +#include +#include +#include + +namespace Catch { + namespace Detail { + + struct EnumInfo { + StringRef m_name; + std::vector> m_values; + + StringRef lookup( int64_t value ) const; + }; + + EnumInfo makeEnumInfo( StringRef enumName, + StringRef allValueNames, + std::vector const& values ); + template + Detail::EnumInfo makeEnumInfo( StringRef enumName, + StringRef allEnums, + std::initializer_list values ) { + static_assert( sizeof( int64_t ) >= sizeof( E ), + "Cannot serialize enum to int64_t" ); + std::vector intValues; + intValues.reserve( values.size() ); + for ( auto enumValue : values ) + intValues.push_back( static_cast( enumValue ) ); + return makeEnumInfo( enumName, allEnums, intValues ); + } + + std::vector parseEnums( StringRef enums ); + + } // namespace Detail +} // namespace Catch + +#endif // CATCH_ENUM_INFO_HPP_INCLUDED diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_values_registry.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_values_registry.hpp deleted file mode 100644 index de994c3597..0000000000 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_enum_values_registry.hpp +++ /dev/null @@ -1,36 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED -#define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED - -#include -#include -#include - -#include - -namespace Catch { - - namespace Detail { - - Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); - - class EnumValuesRegistry : public IMutableEnumValuesRegistry { - - std::vector> m_enumInfos; - - EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values) override; - }; - - std::vector parseEnums( StringRef enums ); - - } // Detail - -} // Catch - -#endif // CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_exception_translator_registry.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_exception_translator_registry.hpp index 32917d41a8..d00fdd25c1 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_exception_translator_registry.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_exception_translator_registry.hpp @@ -15,7 +15,7 @@ namespace Catch { - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + class ExceptionTranslatorRegistry final : public IExceptionTranslatorRegistry { public: ~ExceptionTranslatorRegistry() override; void registerTranslator( Detail::unique_ptr&& translator ); diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_run_context.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_run_context.hpp index dee851e046..f333735db3 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_run_context.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_run_context.hpp @@ -102,8 +102,6 @@ namespace Catch { void handleFatalErrorCondition( StringRef message ) override; - bool lastAssertionPassed() override; - public: // !TBD We need to do this another way! bool aborting() const; @@ -125,7 +123,7 @@ namespace Catch { ITransientExpression const *expr, bool negated ); - void populateReaction( AssertionReaction& reaction, bool has_normal_disposition ); + void populateReaction( AssertionReaction& reaction, bool has_normal_disposition ) const; // Creates dummy info for unexpected exceptions/fatal errors, // where we do not have the access to one, but we still need diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_singletons.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_singletons.hpp index a28a13daa5..74dc6bb0fa 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_singletons.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_singletons.hpp @@ -20,7 +20,7 @@ namespace Catch { template - class Singleton : SingletonImplT, public ISingleton { + class Singleton final : SingletonImplT, public ISingleton { static auto getInternal() -> Singleton* { static Singleton* s_instance = nullptr; diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_tag_alias_registry.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_tag_alias_registry.hpp index 64c0f8f3cd..a359b49506 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_tag_alias_registry.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_tag_alias_registry.hpp @@ -17,7 +17,7 @@ namespace Catch { struct SourceLineInfo; - class TagAliasRegistry : public ITagAliasRegistry { + class TagAliasRegistry final : public ITagAliasRegistry { public: ~TagAliasRegistry() override; TagAlias const* find( std::string const& alias ) const override; diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_case_registry_impl.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_case_registry_impl.hpp index fbca89f900..52c167325c 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_case_registry_impl.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_case_registry_impl.hpp @@ -28,7 +28,7 @@ namespace Catch { std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); std::vector const& getAllTestCasesSorted( IConfig const& config ); - class TestRegistry : public ITestCaseRegistry { + class TestRegistry final : public ITestCaseRegistry { public: void registerTest( Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker ); diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_macro_impl.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_macro_impl.hpp index ccd5bb3578..f38ec6066c 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_macro_impl.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_macro_impl.hpp @@ -11,10 +11,16 @@ #include #include #include -#include #include #include +namespace Catch { + namespace Detail { + // Defined in catch_run_context.cpp, where the thread-local data lives. + bool lastAssertionPassed(); + } +} + // We need this suppression to leak, because it took until GCC 10 // for the front end to handle local suppression via _Pragma properly #if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ <= 9 @@ -57,12 +63,12 @@ /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ - if( Catch::getResultCapture().lastAssertionPassed() ) + if( Catch::Detail::lastAssertionPassed() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ - if( !Catch::getResultCapture().lastAssertionPassed() ) + if( !Catch::Detail::lastAssertionPassed() ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ diff --git a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_registry.hpp b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_registry.hpp index 5c3a226d63..213b2bdcb3 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_registry.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/internal/catch_test_registry.hpp @@ -29,7 +29,7 @@ namespace Catch { template -class TestInvokerAsMethod : public ITestInvoker { +class TestInvokerAsMethod final : public ITestInvoker { void (C::*m_testAsMethod)(); public: constexpr TestInvokerAsMethod( void ( C::*testAsMethod )() ) noexcept: @@ -49,7 +49,7 @@ Detail::unique_ptr makeTestInvoker( void (C::*testAsMethod)() ) { } template -class TestInvokerFixture : public ITestInvoker { +class TestInvokerFixture final : public ITestInvoker { void ( C::*m_testAsMethod )() const; Detail::unique_ptr m_fixture = nullptr; @@ -124,7 +124,7 @@ struct AutoReg : Detail::NonCopyable { namespace Catch { namespace Detail { struct DummyUse { - DummyUse( void ( * )( int ), Catch::NameAndTags const& ); + DummyUse( void ( * )( int ), Catch::NameAndTags const& ) noexcept; }; } // namespace Detail } // namespace Catch diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers.hpp index 90ed333854..6d30c7f04b 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers.hpp @@ -20,10 +20,10 @@ namespace Matchers { class MatcherUntypedBase { public: - MatcherUntypedBase() = default; + constexpr MatcherUntypedBase() = default; - MatcherUntypedBase(MatcherUntypedBase const&) = default; - MatcherUntypedBase(MatcherUntypedBase&&) = default; + constexpr MatcherUntypedBase(MatcherUntypedBase const&) = default; + constexpr MatcherUntypedBase(MatcherUntypedBase&&) = default; MatcherUntypedBase& operator = (MatcherUntypedBase const&) = delete; MatcherUntypedBase& operator = (MatcherUntypedBase&&) = delete; @@ -31,9 +31,9 @@ namespace Matchers { std::string toString() const; protected: - virtual ~MatcherUntypedBase(); // = default; - virtual std::string describe() const = 0; - mutable std::string m_cachedToString; + CATCH_DESTRUCTOR_CONSTEXPR virtual ~MatcherUntypedBase() = default; + //! Should be overridden, but we provide default "undescribed" impl + virtual std::string describe() const; }; @@ -215,6 +215,19 @@ namespace Matchers { #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) + #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) + #define CATCH_STATIC_REQUIRE_THAT( arg, matcher ) \ + static_assert( ( matcher ).match( arg ), #matcher ".match( " #arg " )"); \ + CATCH_SUCCEED( #matcher ".match( " #arg " )" ) + #define CATCH_STATIC_CHECK_THAT( arg, matcher ) \ + static_assert( ( matcher ).match( arg ), #matcher ".match( " #arg " )"); \ + CATCH_SUCCEED( #matcher ".match( " #arg " )" ) + #else + #define CATCH_STATIC_REQUIRE_THAT( arg, matcher ) CATCH_REQUIRE_THAT( arg, matcher ) + #define CATCH_STATIC_CHECK_THAT( arg, matcher ) CATCH_CHECK_THAT( arg, matcher ) + #endif + + #elif defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) @@ -226,6 +239,9 @@ namespace Matchers { #define CATCH_CHECK_THAT( arg, matcher ) (void)(0) #define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) + #define CATCH_STATIC_REQUIRE_THAT( arg, matcher ) (void)(0) + #define CATCH_STATIC_CHECK_THAT( arg, matcher ) (void)(0) + #elif !defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_DISABLE) #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) @@ -237,6 +253,19 @@ namespace Matchers { #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) + #if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE) + #define STATIC_REQUIRE_THAT( arg, matcher ) \ + static_assert( ( matcher ).match( arg ), #matcher ".match( " #arg " )"); \ + SUCCEED( #matcher ".match( " #arg " )" ) + #define STATIC_CHECK_THAT( arg, matcher ) \ + static_assert( ( matcher ).match( arg ), #matcher ".match( " #arg " )"); \ + SUCCEED( #matcher ".match( " #arg " )" ) + #else + #define STATIC_REQUIRE_THAT( arg, matcher ) REQUIRE_THAT( arg, matcher ) + #define STATIC_CHECK_THAT( arg, matcher ) CHECK_THAT( arg, matcher ) + #endif + + #elif !defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CONFIG_DISABLE) #define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) @@ -248,6 +277,9 @@ namespace Matchers { #define CHECK_THAT( arg, matcher ) (void)(0) #define REQUIRE_THAT( arg, matcher ) (void)(0) + #define STATIC_REQUIRE_THAT( arg, matcher ) (void)(0) + #define STATIC_CHECK_THAT( arg, matcher ) (void)(0) + #endif // end of user facing macro declarations #endif // CATCH_MATCHERS_HPP_INCLUDED diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_container_properties.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_container_properties.hpp index 33795fbed3..552bbab13a 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_container_properties.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_container_properties.hpp @@ -18,7 +18,7 @@ namespace Catch { class IsEmptyMatcher final : public MatcherGenericBase { public: template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) using Catch::Detail::empty; #else @@ -33,12 +33,12 @@ namespace Catch { class HasSizeMatcher final : public MatcherGenericBase { std::size_t m_target_size; public: - explicit HasSizeMatcher(std::size_t target_size): + constexpr explicit HasSizeMatcher(std::size_t target_size): m_target_size(target_size) {} template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) using Catch::Detail::size; #else @@ -54,12 +54,12 @@ namespace Catch { class SizeMatchesMatcher final : public MatcherGenericBase { Matcher m_matcher; public: - explicit SizeMatchesMatcher(Matcher m): + constexpr explicit SizeMatchesMatcher(Matcher m): m_matcher(CATCH_MOVE(m)) {} template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { #if defined(CATCH_CONFIG_POLYFILL_NONMEMBER_CONTAINER_ACCESS) using Catch::Detail::size; #else @@ -75,11 +75,13 @@ namespace Catch { //! Creates a matcher that accepts empty ranges/containers - IsEmptyMatcher IsEmpty(); + inline CATCH_DESTRUCTOR_CONSTEXPR IsEmptyMatcher IsEmpty() { return {}; } //! Creates a matcher that accepts ranges/containers with specific size - HasSizeMatcher SizeIs(std::size_t sz); + inline CATCH_DESTRUCTOR_CONSTEXPR HasSizeMatcher SizeIs( std::size_t sz ) { + return HasSizeMatcher{ sz }; + } template - std::enable_if_t, + constexpr std::enable_if_t, SizeMatchesMatcher> SizeIs(Matcher&& m) { return SizeMatchesMatcher{CATCH_FORWARD(m)}; } diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_contains.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_contains.hpp index 90cfe641e2..8516803096 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_contains.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_contains.hpp @@ -23,7 +23,7 @@ namespace Catch { Equality m_eq; public: template - ContainsElementMatcher(T2&& target, Equality2&& predicate): + constexpr ContainsElementMatcher(T2&& target, Equality2&& predicate): m_desired(CATCH_FORWARD(target)), m_eq(CATCH_FORWARD(predicate)) {} @@ -33,7 +33,7 @@ namespace Catch { } template - bool match( RangeLike&& rng ) const { + constexpr bool match( RangeLike&& rng ) const { for ( auto&& elem : rng ) { if ( m_eq( elem, m_desired ) ) { return true; } } @@ -49,12 +49,12 @@ namespace Catch { // Note that we do a copy+move to avoid having to SFINAE this // constructor (and also avoid some perfect forwarding failure // cases) - ContainsMatcherMatcher(Matcher matcher): + constexpr ContainsMatcherMatcher(Matcher matcher): m_matcher(CATCH_MOVE(matcher)) {} template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (m_matcher.match(elem)) { return true; @@ -74,14 +74,14 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template - std::enable_if_t, + constexpr std::enable_if_t, ContainsElementMatcher>> Contains(T&& elem) { return { CATCH_FORWARD(elem), std::equal_to<>{} }; } //! Creates a matcher that checks whether a range contains element matching a matcher template - std::enable_if_t, + constexpr std::enable_if_t, ContainsMatcherMatcher> Contains(Matcher&& matcher) { return { CATCH_FORWARD(matcher) }; } @@ -92,7 +92,7 @@ namespace Catch { * Uses `eq` to do the comparisons, the element is provided on the rhs */ template - ContainsElementMatcher Contains(T&& elem, Equality&& eq) { + constexpr ContainsElementMatcher Contains(T&& elem, Equality&& eq) { return { CATCH_FORWARD(elem), CATCH_FORWARD(eq) }; } diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_quantifiers.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_quantifiers.hpp index 977b0c762c..566846488f 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_quantifiers.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_quantifiers.hpp @@ -18,7 +18,7 @@ namespace Catch { class AllMatchMatcher final : public MatcherGenericBase { Matcher m_matcher; public: - AllMatchMatcher(Matcher matcher): + constexpr AllMatchMatcher(Matcher matcher): m_matcher(CATCH_MOVE(matcher)) {} @@ -27,7 +27,7 @@ namespace Catch { } template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (!m_matcher.match(elem)) { return false; @@ -42,7 +42,7 @@ namespace Catch { class NoneMatchMatcher final : public MatcherGenericBase { Matcher m_matcher; public: - NoneMatchMatcher(Matcher matcher): + constexpr NoneMatchMatcher(Matcher matcher): m_matcher(CATCH_MOVE(matcher)) {} @@ -51,7 +51,7 @@ namespace Catch { } template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (m_matcher.match(elem)) { return false; @@ -66,7 +66,7 @@ namespace Catch { class AnyMatchMatcher final : public MatcherGenericBase { Matcher m_matcher; public: - AnyMatchMatcher(Matcher matcher): + constexpr AnyMatchMatcher(Matcher matcher): m_matcher(CATCH_MOVE(matcher)) {} @@ -75,7 +75,7 @@ namespace Catch { } template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (m_matcher.match(elem)) { return true; @@ -91,7 +91,7 @@ namespace Catch { std::string describe() const override; template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (!elem) { return false; @@ -107,7 +107,7 @@ namespace Catch { std::string describe() const override; template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (elem) { return false; @@ -123,7 +123,7 @@ namespace Catch { std::string describe() const override; template - bool match(RangeLike&& rng) const { + constexpr bool match(RangeLike&& rng) const { for (auto&& elem : rng) { if (elem) { return true; @@ -133,32 +133,35 @@ namespace Catch { } }; - // Creates a matcher that checks whether all elements in a range match a matcher + //! Creates a matcher that checks whether all elements in a range match a matcher template - AllMatchMatcher AllMatch(Matcher&& matcher) { + constexpr AllMatchMatcher AllMatch(Matcher&& matcher) { return { CATCH_FORWARD(matcher) }; } - // Creates a matcher that checks whether no element in a range matches a matcher. + //! Creates a matcher that checks whether no element in a range matches a matcher. template - NoneMatchMatcher NoneMatch(Matcher&& matcher) { + constexpr NoneMatchMatcher NoneMatch(Matcher&& matcher) { return { CATCH_FORWARD(matcher) }; } - // Creates a matcher that checks whether any element in a range matches a matcher. + //! Creates a matcher that checks whether any element in a range matches a matcher. template - AnyMatchMatcher AnyMatch(Matcher&& matcher) { + constexpr AnyMatchMatcher AnyMatch(Matcher&& matcher) { return { CATCH_FORWARD(matcher) }; } - // Creates a matcher that checks whether all elements in a range are true - AllTrueMatcher AllTrue(); + //! Creates a matcher that checks whether all elements in a range are true + inline CATCH_DESTRUCTOR_CONSTEXPR + AllTrueMatcher AllTrue() { return AllTrueMatcher{}; } - // Creates a matcher that checks whether no element in a range is true - NoneTrueMatcher NoneTrue(); + //! Creates a matcher that checks whether no element in a range is true + inline CATCH_DESTRUCTOR_CONSTEXPR + NoneTrueMatcher NoneTrue() { return NoneTrueMatcher{}; } - // Creates a matcher that checks whether any element in a range is true - AnyTrueMatcher AnyTrue(); + //! Creates a matcher that checks whether any element in a range is true + inline CATCH_DESTRUCTOR_CONSTEXPR + AnyTrueMatcher AnyTrue() { return AnyTrueMatcher{}; } } } diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_templated.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_templated.hpp index 0cd4016365..2c6247f864 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_templated.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/catch_matchers_templated.hpp @@ -22,12 +22,12 @@ namespace Catch { namespace Matchers { class MatcherGenericBase : public MatcherUntypedBase { + std::string describe() const override; public: - MatcherGenericBase() = default; - ~MatcherGenericBase() override; // = default; + constexpr MatcherGenericBase() = default; - MatcherGenericBase(MatcherGenericBase const&) = default; - MatcherGenericBase(MatcherGenericBase&&) = default; + constexpr MatcherGenericBase(MatcherGenericBase const&) = default; + constexpr MatcherGenericBase(MatcherGenericBase&&) = default; MatcherGenericBase& operator=(MatcherGenericBase const&) = delete; MatcherGenericBase& operator=(MatcherGenericBase&&) = delete; @@ -36,7 +36,9 @@ namespace Matchers { namespace Detail { template - std::array array_cat(std::array && lhs, std::array && rhs) { + constexpr std::array + array_cat( std::array&& lhs, + std::array&& rhs ) { std::array arr{}; std::copy_n(lhs.begin(), N, arr.begin()); std::copy_n(rhs.begin(), M, arr.begin() + N); @@ -44,7 +46,8 @@ namespace Matchers { } template - std::array array_cat(std::array && lhs, void const* rhs) { + constexpr std::array + array_cat( std::array&& lhs, void const* rhs ) { std::array arr{}; std::copy_n(lhs.begin(), N, arr.begin()); arr[N] = rhs; @@ -52,7 +55,8 @@ namespace Matchers { } template - std::array array_cat(void const* lhs, std::array && rhs) { + constexpr std::array + array_cat( void const* lhs, std::array&& rhs ) { std::array arr{ {lhs} }; std::copy_n(rhs.begin(), N, arr.begin() + 1); return arr; @@ -75,23 +79,31 @@ namespace Matchers { template - bool match_all_of(Arg&&, std::array const&, std::index_sequence<>) { + constexpr bool match_all_of( Arg&&, + std::array const&, + std::index_sequence<> ) { return true; } template - bool match_all_of(Arg&& arg, std::array const& matchers, std::index_sequence) { + constexpr bool match_all_of( Arg&& arg, + std::array const& matchers, + std::index_sequence ) { return static_cast(matchers[Idx])->match(arg) && match_all_of(arg, matchers, std::index_sequence{}); } template - bool match_any_of(Arg&&, std::array const&, std::index_sequence<>) { + constexpr bool match_any_of( Arg&&, + std::array const&, + std::index_sequence<> ) { return false; } template - bool match_any_of(Arg&& arg, std::array const& matchers, std::index_sequence) { + constexpr bool match_any_of( Arg&& arg, + std::array const& matchers, + std::index_sequence ) { return static_cast(matchers[Idx])->match(arg) || match_any_of(arg, matchers, std::index_sequence{}); } @@ -112,15 +124,18 @@ namespace Matchers { public: MatchAllOfGeneric(MatchAllOfGeneric const&) = delete; MatchAllOfGeneric& operator=(MatchAllOfGeneric const&) = delete; - MatchAllOfGeneric(MatchAllOfGeneric&&) = default; - MatchAllOfGeneric& operator=(MatchAllOfGeneric&&) = default; + constexpr MatchAllOfGeneric( MatchAllOfGeneric&& ) = default; + constexpr MatchAllOfGeneric& operator=(MatchAllOfGeneric&&) = default; - MatchAllOfGeneric(MatcherTs const&... matchers CATCH_ATTR_LIFETIMEBOUND) + constexpr MatchAllOfGeneric( + MatcherTs const&... matchers CATCH_ATTR_LIFETIMEBOUND ) : m_matchers{ {std::addressof(matchers)...} } {} - explicit MatchAllOfGeneric(std::array matchers) : m_matchers{matchers} {} + constexpr explicit MatchAllOfGeneric( + std::array matchers ): + m_matchers{ matchers } {} template - bool match(Arg&& arg) const { + constexpr bool match( Arg&& arg ) const { return match_all_of(arg, m_matchers, std::index_sequence_for{}); } @@ -136,7 +151,7 @@ namespace Matchers { //! Avoids type nesting for `GenericAllOf && GenericAllOf` case template - friend + constexpr friend MatchAllOfGeneric operator && ( MatchAllOfGeneric&& lhs CATCH_ATTR_LIFETIMEBOUND, MatchAllOfGeneric&& rhs CATCH_ATTR_LIFETIMEBOUND ) { @@ -145,7 +160,8 @@ namespace Matchers { //! Avoids type nesting for `GenericAllOf && some matcher` case template - friend std::enable_if_t, + constexpr friend std::enable_if_t< + is_matcher_v, MatchAllOfGeneric> operator && ( MatchAllOfGeneric&& lhs CATCH_ATTR_LIFETIMEBOUND, MatcherRHS const& rhs CATCH_ATTR_LIFETIMEBOUND ) { @@ -154,7 +170,8 @@ namespace Matchers { //! Avoids type nesting for `some matcher && GenericAllOf` case template - friend std::enable_if_t, + constexpr friend std::enable_if_t< + is_matcher_v, MatchAllOfGeneric> operator && ( MatcherLHS const& lhs CATCH_ATTR_LIFETIMEBOUND, MatchAllOfGeneric&& rhs CATCH_ATTR_LIFETIMEBOUND ) { @@ -168,15 +185,18 @@ namespace Matchers { public: MatchAnyOfGeneric(MatchAnyOfGeneric const&) = delete; MatchAnyOfGeneric& operator=(MatchAnyOfGeneric const&) = delete; - MatchAnyOfGeneric(MatchAnyOfGeneric&&) = default; - MatchAnyOfGeneric& operator=(MatchAnyOfGeneric&&) = default; + constexpr MatchAnyOfGeneric( MatchAnyOfGeneric&& ) = default; + constexpr MatchAnyOfGeneric& operator=(MatchAnyOfGeneric&&) = default; - MatchAnyOfGeneric(MatcherTs const&... matchers CATCH_ATTR_LIFETIMEBOUND) + constexpr MatchAnyOfGeneric( + MatcherTs const&... matchers CATCH_ATTR_LIFETIMEBOUND ) : m_matchers{ {std::addressof(matchers)...} } {} - explicit MatchAnyOfGeneric(std::array matchers) : m_matchers{matchers} {} + constexpr explicit MatchAnyOfGeneric( + std::array matchers ): + m_matchers{ matchers } {} template - bool match(Arg&& arg) const { + constexpr bool match( Arg&& arg ) const { return match_any_of(arg, m_matchers, std::index_sequence_for{}); } @@ -192,7 +212,8 @@ namespace Matchers { //! Avoids type nesting for `GenericAnyOf || GenericAnyOf` case template - friend MatchAnyOfGeneric operator || ( + constexpr friend MatchAnyOfGeneric + operator||( MatchAnyOfGeneric&& lhs CATCH_ATTR_LIFETIMEBOUND, MatchAnyOfGeneric&& rhs CATCH_ATTR_LIFETIMEBOUND ) { return MatchAnyOfGeneric{array_cat(CATCH_MOVE(lhs.m_matchers), CATCH_MOVE(rhs.m_matchers))}; @@ -200,7 +221,8 @@ namespace Matchers { //! Avoids type nesting for `GenericAnyOf || some matcher` case template - friend std::enable_if_t, + constexpr friend std::enable_if_t< + is_matcher_v, MatchAnyOfGeneric> operator || ( MatchAnyOfGeneric&& lhs CATCH_ATTR_LIFETIMEBOUND, MatcherRHS const& rhs CATCH_ATTR_LIFETIMEBOUND ) { @@ -209,7 +231,8 @@ namespace Matchers { //! Avoids type nesting for `some matcher || GenericAnyOf` case template - friend std::enable_if_t, + constexpr friend std::enable_if_t< + is_matcher_v, MatchAnyOfGeneric> operator || ( MatcherLHS const& lhs CATCH_ATTR_LIFETIMEBOUND, MatchAnyOfGeneric&& rhs CATCH_ATTR_LIFETIMEBOUND) { @@ -225,14 +248,15 @@ namespace Matchers { public: MatchNotOfGeneric(MatchNotOfGeneric const&) = delete; MatchNotOfGeneric& operator=(MatchNotOfGeneric const&) = delete; - MatchNotOfGeneric(MatchNotOfGeneric&&) = default; - MatchNotOfGeneric& operator=(MatchNotOfGeneric&&) = default; + constexpr MatchNotOfGeneric( MatchNotOfGeneric&& ) = default; + constexpr MatchNotOfGeneric& operator=(MatchNotOfGeneric&&) = default; - explicit MatchNotOfGeneric(MatcherT const& matcher CATCH_ATTR_LIFETIMEBOUND) + constexpr explicit MatchNotOfGeneric( + MatcherT const& matcher CATCH_ATTR_LIFETIMEBOUND ) : m_matcher{matcher} {} template - bool match(Arg&& arg) const { + constexpr bool match( Arg&& arg ) const { return !m_matcher.match(arg); } @@ -241,7 +265,7 @@ namespace Matchers { } //! Negating negation can just unwrap and return underlying matcher - friend MatcherT const& + constexpr friend MatcherT const& operator!( MatchNotOfGeneric const& matcher CATCH_ATTR_LIFETIMEBOUND ) { return matcher.m_matcher; @@ -252,14 +276,18 @@ namespace Matchers { // compose only generic matchers template - std::enable_if_t, Detail::MatchAllOfGeneric> + constexpr std::enable_if_t< + Detail::are_generic_matchers_v, + Detail::MatchAllOfGeneric> operator&&( MatcherLHS const& lhs CATCH_ATTR_LIFETIMEBOUND, MatcherRHS const& rhs CATCH_ATTR_LIFETIMEBOUND ) { return { lhs, rhs }; } template - std::enable_if_t, Detail::MatchAnyOfGeneric> + constexpr std::enable_if_t< + Detail::are_generic_matchers_v, + Detail::MatchAnyOfGeneric> operator||( MatcherLHS const& lhs CATCH_ATTR_LIFETIMEBOUND, MatcherRHS const& rhs CATCH_ATTR_LIFETIMEBOUND ) { return { lhs, rhs }; @@ -267,7 +295,8 @@ namespace Matchers { //! Wrap provided generic matcher in generic negator template - std::enable_if_t, Detail::MatchNotOfGeneric> + constexpr std::enable_if_t, + Detail::MatchNotOfGeneric> operator!( MatcherT const& matcher CATCH_ATTR_LIFETIMEBOUND ) { return Detail::MatchNotOfGeneric{matcher}; } diff --git a/thirdparty/catch2/src/main/native/include/catch2/matchers/internal/catch_matchers_impl.hpp b/thirdparty/catch2/src/main/native/include/catch2/matchers/internal/catch_matchers_impl.hpp index 24a3f8b690..1aa503853b 100644 --- a/thirdparty/catch2/src/main/native/include/catch2/matchers/internal/catch_matchers_impl.hpp +++ b/thirdparty/catch2/src/main/native/include/catch2/matchers/internal/catch_matchers_impl.hpp @@ -29,7 +29,7 @@ namespace Catch { #endif template - class MatchExpr : public ITransientExpression { + class MatchExpr final : public ITransientExpression { ArgT && m_arg; MatcherT const& m_matcher; public: diff --git a/upstream_utils/catch2.py b/upstream_utils/catch2.py index 165a71e31c..0d5d6da779 100755 --- a/upstream_utils/catch2.py +++ b/upstream_utils/catch2.py @@ -49,7 +49,7 @@ def copy_upstream_src(wpilib_root: Path): def main(): name = "catch2" url = "https://github.com/catchorg/Catch2.git" - tag = "v3.14.0" + tag = "v3.15.0" patch_options = { "ignore_whitespace": True,