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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-04-08 10:26:57 +0200
committerMartin Hořeňovský2026-04-08 12:57:09 +0200
commit47200ddbee03eaf4a9d3d99d18cb692381d8f5bc (patch)
treeec947545e5f35b38ea5592c6fafcd7861081648c
parente51dcdcc595371828de2b1d28985e8d8c1895345 (diff)
downloadcatch3-47200ddbee03eaf4a9d3d99d18cb692381d8f5bc.tar.gz
Rework internals of CATCH_REGISTER_ENUM
The old internals reached into the global hub to stash the allocation(s) for enum value -> string value there, then kept around a potentially invalid (in case the hub was cleaned up) reference into it, going through whole bunch of virtual dispatch in the process. The new internals just store the data in a static variable inside the `StringMaker` specialization. This avoids potential lifetime issues, avoids all virtual dispatch and (almost) reduces the include bloat in the main header path. The reason for (almost) there is that for full include correctness, `EnumInfo` needs `<utility>` include for `std::pair`. However, this brings in things like `std::relops`, because the std headers in C++ are dumb. As this was not included before, and instead we relied on `std::pair` existing in an internal stdlib header that we transitively included, the full include size ends up bigger than before.
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/catch2/catch_all.hpp2
-rw-r--r--src/catch2/catch_message.hpp1
-rw-r--r--src/catch2/catch_registry_hub.cpp5
-rw-r--r--src/catch2/catch_session.cpp1
-rw-r--r--src/catch2/catch_tostring.hpp29
-rw-r--r--src/catch2/interfaces/catch_interfaces_all.hpp1
-rw-r--r--src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp47
-rw-r--r--src/catch2/interfaces/catch_interfaces_registry_hub.hpp1
-rw-r--r--src/catch2/internal/catch_assertion_handler.cpp1
-rw-r--r--src/catch2/internal/catch_enum_info.cpp (renamed from src/catch2/internal/catch_enum_values_registry.cpp)28
-rw-r--r--src/catch2/internal/catch_enum_info.hpp48
-rw-r--r--src/catch2/internal/catch_enum_values_registry.hpp36
-rw-r--r--src/catch2/internal/catch_run_context.cpp1
-rw-r--r--src/catch2/meson.build5
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/automake.sw.multi.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt27
-rw-r--r--tests/SelfTest/Baselines/compact.sw.multi.approved.txt27
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt59
-rw-r--r--tests/SelfTest/Baselines/console.sw.multi.approved.txt59
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/junit.sw.multi.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt11
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt14
-rw-r--r--tests/SelfTest/Baselines/tap.sw.multi.approved.txt14
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt67
-rw-r--r--tests/SelfTest/Baselines/xml.sw.multi.approved.txt67
-rw-r--r--tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp1
-rw-r--r--tests/SelfTest/IntrospectiveTests/ToString.tests.cpp40
-rw-r--r--tests/SelfTest/UsageTests/EnumToString.tests.cpp87
35 files changed, 405 insertions, 306 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 11089ff5..0ed64ebf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -87,7 +87,7 @@ set(IMPL_HEADERS
${SOURCES_DIR}/internal/catch_decomposer.hpp
${SOURCES_DIR}/internal/catch_deprecation_macro.hpp
${SOURCES_DIR}/internal/catch_enforce.hpp
- ${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
+ ${SOURCES_DIR}/internal/catch_enum_info.hpp
${SOURCES_DIR}/internal/catch_errno_guard.hpp
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
@@ -181,7 +181,7 @@ set(IMPL_SOURCES
${SOURCES_DIR}/internal/catch_debugger.cpp
${SOURCES_DIR}/internal/catch_decomposer.cpp
${SOURCES_DIR}/internal/catch_enforce.cpp
- ${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
+ ${SOURCES_DIR}/internal/catch_enum_info.cpp
${SOURCES_DIR}/internal/catch_errno_guard.cpp
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
@@ -227,7 +227,6 @@ set(INTERFACE_HEADERS
${SOURCES_DIR}/interfaces/catch_interfaces_all.hpp
${SOURCES_DIR}/interfaces/catch_interfaces_capture.hpp
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
- ${SOURCES_DIR}/interfaces/catch_interfaces_enum_values_registry.hpp
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index 97226dd1..82b11405 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -68,7 +68,7 @@
#include <catch2/internal/catch_decomposer.hpp>
#include <catch2/internal/catch_deprecation_macro.hpp>
#include <catch2/internal/catch_enforce.hpp>
-#include <catch2/internal/catch_enum_values_registry.hpp>
+#include <catch2/internal/catch_enum_info.hpp>
#include <catch2/internal/catch_errno_guard.hpp>
#include <catch2/internal/catch_exception_translator_registry.hpp>
#include <catch2/internal/catch_fatal_condition_handler.hpp>
diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp
index 4958716d..4582654f 100644
--- a/src/catch2/catch_message.hpp
+++ b/src/catch2/catch_message.hpp
@@ -13,6 +13,7 @@
#include <catch2/internal/catch_reusable_string_stream.hpp>
#include <catch2/internal/catch_stream_end_stop.hpp>
#include <catch2/internal/catch_message_info.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/catch_tostring.hpp>
#include <string>
diff --git a/src/catch2/catch_registry_hub.cpp b/src/catch2/catch_registry_hub.cpp
index 925468fa..25aecdde 100644
--- a/src/catch2/catch_registry_hub.cpp
+++ b/src/catch2/catch_registry_hub.cpp
@@ -15,7 +15,6 @@
#include <catch2/internal/catch_tag_alias_registry.hpp>
#include <catch2/internal/catch_startup_exception_registry.hpp>
#include <catch2/internal/catch_singletons.hpp>
-#include <catch2/internal/catch_enum_values_registry.hpp>
#include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
@@ -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/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp
index 042b7f4d..0487fe75 100644
--- a/src/catch2/catch_session.cpp
+++ b/src/catch2/catch_session.cpp
@@ -21,6 +21,7 @@
#include <catch2/reporters/catch_reporter_multi.hpp>
#include <catch2/internal/catch_reporter_registry.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_stdstreams.hpp>
#include <catch2/internal/catch_istream.hpp>
diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp
index b005212f..16c4c496 100644
--- a/src/catch2/catch_tostring.hpp
+++ b/src/catch2/catch_tostring.hpp
@@ -18,7 +18,8 @@
#include <catch2/internal/catch_config_wchar.hpp>
#include <catch2/internal/catch_reusable_string_stream.hpp>
#include <catch2/internal/catch_void_type.hpp>
-#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
+#include <catch2/internal/catch_enum_info.hpp>
+#include <catch2/internal/catch_stringref.hpp>
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
#include <string_view>
@@ -630,17 +631,21 @@ struct ratio_string<std::milli> {
};
}
-#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
-
-#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
-namespace Catch { \
- template<> struct StringMaker<enumName> { \
- static std::string convert( enumName value ) { \
- static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \
- return static_cast<std::string>(enumInfo.lookup( static_cast<int>( value ) )); \
- } \
- }; \
-}
+#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
+ namespace Catch { \
+ template <> \
+ struct StringMaker<enumName> { \
+ 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<std::string>( \
+ enumInfo.lookup( static_cast<int64_t>( value ) ) ); \
+ } \
+ }; \
+ }
#define CATCH_REGISTER_ENUM( enumName, ... ) INTERNAL_CATCH_REGISTER_ENUM( enumName, __VA_ARGS__ )
diff --git a/src/catch2/interfaces/catch_interfaces_all.hpp b/src/catch2/interfaces/catch_interfaces_all.hpp
index a99fdcdc..87eb259b 100644
--- a/src/catch2/interfaces/catch_interfaces_all.hpp
+++ b/src/catch2/interfaces/catch_interfaces_all.hpp
@@ -24,7 +24,6 @@
#include <catch2/interfaces/catch_interfaces_capture.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
-#include <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
#include <catch2/interfaces/catch_interfaces_exception.hpp>
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
diff --git a/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp b/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp
deleted file mode 100644
index 38b052d9..00000000
--- a/src/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 <catch2/internal/catch_stringref.hpp>
-
-#include <vector>
-
-namespace Catch {
-
- namespace Detail {
- struct EnumInfo {
- StringRef m_name;
- std::vector<std::pair<int, StringRef>> 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<int> const& values ) = 0;
-
- template<typename E>
- Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list<E> values ) {
- static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int");
- std::vector<int> intValues;
- intValues.reserve( values.size() );
- for( auto enumValue : values )
- intValues.push_back( static_cast<int>( enumValue ) );
- return registerEnum( enumName, allEnums, intValues );
- }
- };
-
-} // Catch
-
-#endif // CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED
diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
index 113f223e..3695a192 100644
--- a/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
+++ b/src/catch2/interfaces/catch_interfaces_registry_hub.hpp
@@ -53,7 +53,6 @@ namespace Catch {
virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0;
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
virtual void registerStartupException() noexcept = 0;
- virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0;
};
IRegistryHub const& getRegistryHub();
diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp
index a0fcfcb4..5a4806e9 100644
--- a/src/catch2/internal/catch_assertion_handler.cpp
+++ b/src/catch2/internal/catch_assertion_handler.cpp
@@ -8,6 +8,7 @@
#include <catch2/internal/catch_assertion_handler.hpp>
#include <catch2/interfaces/catch_interfaces_capture.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_context.hpp>
#include <catch2/internal/catch_debugger.hpp>
#include <catch2/internal/catch_test_failure_exception.hpp>
diff --git a/src/catch2/internal/catch_enum_values_registry.cpp b/src/catch2/internal/catch_enum_info.cpp
index a94b6088..0793abd9 100644
--- a/src/catch2/internal/catch_enum_values_registry.cpp
+++ b/src/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 <catch2/internal/catch_enum_values_registry.hpp>
+
+#include <catch2/internal/catch_enum_info.hpp>
#include <catch2/internal/catch_string_manip.hpp>
#include <cassert>
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<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values ) {
- auto enumInfo = Catch::Detail::make_unique<EnumInfo>();
- enumInfo->m_name = enumName;
- enumInfo->m_values.reserve( values.size() );
+ EnumInfo makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int64_t> 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<int> const& values ) {
- m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values));
- return *m_enumInfos.back();
- }
-
} // Detail
} // Catch
diff --git a/src/catch2/internal/catch_enum_info.hpp b/src/catch2/internal/catch_enum_info.hpp
new file mode 100644
index 00000000..b3036a82
--- /dev/null
+++ b/src/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 <catch2/internal/catch_stringref.hpp>
+
+#include <cstdint>
+#include <utility>
+#include <vector>
+
+namespace Catch {
+ namespace Detail {
+
+ struct EnumInfo {
+ StringRef m_name;
+ std::vector<std::pair<int64_t, StringRef>> m_values;
+
+ StringRef lookup( int64_t value ) const;
+ };
+
+ EnumInfo makeEnumInfo( StringRef enumName,
+ StringRef allValueNames,
+ std::vector<int64_t> const& values );
+ template <typename E>
+ Detail::EnumInfo makeEnumInfo( StringRef enumName,
+ StringRef allEnums,
+ std::initializer_list<E> values ) {
+ static_assert( sizeof( int64_t ) >= sizeof( E ),
+ "Cannot serialize enum to int64_t" );
+ std::vector<int64_t> intValues;
+ intValues.reserve( values.size() );
+ for ( auto enumValue : values )
+ intValues.push_back( static_cast<int64_t>( enumValue ) );
+ return makeEnumInfo( enumName, allEnums, intValues );
+ }
+
+ std::vector<StringRef> parseEnums( StringRef enums );
+
+ } // namespace Detail
+} // namespace Catch
+
+#endif // CATCH_ENUM_INFO_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_enum_values_registry.hpp b/src/catch2/internal/catch_enum_values_registry.hpp
deleted file mode 100644
index 7b5e7a72..00000000
--- a/src/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 <catch2/interfaces/catch_interfaces_enum_values_registry.hpp>
-#include <catch2/internal/catch_unique_ptr.hpp>
-#include <catch2/internal/catch_stringref.hpp>
-
-#include <vector>
-
-namespace Catch {
-
- namespace Detail {
-
- Catch::Detail::unique_ptr<EnumInfo> makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector<int> const& values );
-
- class EnumValuesRegistry final : public IMutableEnumValuesRegistry {
-
- std::vector<Catch::Detail::unique_ptr<EnumInfo>> m_enumInfos;
-
- EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values) override;
- };
-
- std::vector<StringRef> parseEnums( StringRef enums );
-
- } // Detail
-
-} // Catch
-
-#endif // CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index 547ff9d8..e7e22c58 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -11,6 +11,7 @@
#include <catch2/generators/catch_generators_throw.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_context.hpp>
diff --git a/src/catch2/meson.build b/src/catch2/meson.build
index f491c602..94e0496a 100644
--- a/src/catch2/meson.build
+++ b/src/catch2/meson.build
@@ -65,7 +65,6 @@ internal_headers = [
'interfaces/catch_interfaces_all.hpp',
'interfaces/catch_interfaces_capture.hpp',
'interfaces/catch_interfaces_config.hpp',
- 'interfaces/catch_interfaces_enum_values_registry.hpp',
'interfaces/catch_interfaces_exception.hpp',
'interfaces/catch_interfaces_generatortracker.hpp',
'interfaces/catch_interfaces_registry_hub.hpp',
@@ -95,7 +94,7 @@ internal_headers = [
'internal/catch_decomposer.hpp',
'internal/catch_deprecation_macro.hpp',
'internal/catch_enforce.hpp',
- 'internal/catch_enum_values_registry.hpp',
+ 'internal/catch_enum_info.hpp',
'internal/catch_errno_guard.hpp',
'internal/catch_exception_translator_registry.hpp',
'internal/catch_fatal_condition_handler.hpp',
@@ -224,7 +223,7 @@ internal_sources = files(
'internal/catch_debugger.cpp',
'internal/catch_decomposer.cpp',
'internal/catch_enforce.cpp',
- 'internal/catch_enum_values_registry.cpp',
+ 'internal/catch_enum_info.cpp',
'internal/catch_errno_guard.cpp',
'internal/catch_exception_translator_registry.cpp',
'internal/catch_fatal_condition_handler.cpp',
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index f5c2fa97..5018a19a 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -144,6 +144,7 @@ Nor would this
:test-result: SKIP Empty generators can SKIP in constructor
:test-result: PASS Empty stream name opens cout stream
:test-result: FAIL EndsWith string matcher
+:test-result: PASS Enum backed by larger underlying type
:test-result: PASS Enums can quickly have stringification enabled using CATCH_REGISTER_ENUM
:test-result: PASS Enums in namespaces can quickly have stringification enabled using CATCH_REGISTER_ENUM
:test-result: PASS Epsilon only applies to Approx's value
diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
index 973e2f53..4f9a9441 100644
--- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt
@@ -142,6 +142,7 @@
:test-result: SKIP Empty generators can SKIP in constructor
:test-result: PASS Empty stream name opens cout stream
:test-result: FAIL EndsWith string matcher
+:test-result: PASS Enum backed by larger underlying type
:test-result: PASS Enums can quickly have stringification enabled using CATCH_REGISTER_ENUM
:test-result: PASS Enums in namespaces can quickly have stringification enabled using CATCH_REGISTER_ENUM
:test-result: PASS Epsilon only applies to Approx's value
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index e4258ecb..cb90a0f5 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -576,15 +576,18 @@ Approx.tests.cpp:<line number>: passed: 101.000001 != Approx(100).epsilon(0.01)
Approx.tests.cpp:<line number>: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 )
Message.tests.cpp:<line number>: passed: true with 1 message: 'a'
Message.tests.cpp:<line number>: failed: false with 1 message: 'b'
-ToString.tests.cpp:<line number>: passed: enumInfo->lookup(0) == "Value1" for: Value1 == "Value1"
-ToString.tests.cpp:<line number>: passed: enumInfo->lookup(1) == "Value2" for: Value2 == "Value2"
-ToString.tests.cpp:<line number>: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **}
+EnumToString.tests.cpp:<line number>: passed: enumInfo.lookup(0) == "Value1" for: Value1 == "Value1"
+EnumToString.tests.cpp:<line number>: passed: enumInfo.lookup(1) == "Value2" for: Value2 == "Value2"
+EnumToString.tests.cpp:<line number>: passed: enumInfo.lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **}
==
"{** unexpected enum value **}"
Skip.tests.cpp:<line number>: skipped: 'This generator is empty'
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "" )->isConsole() for: true
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "Substring" ) for: "this string contains 'abc' as a substring" ends with: "Substring"
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), EndsWith( "this", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive)
+EnumToString.tests.cpp:<line number>: passed: stringify( LargeEnum::Flag1 ) == "Flag1" for: "Flag1" == "Flag1"
+EnumToString.tests.cpp:<line number>: passed: stringify( LargeEnum::Flag2 ) == "Flag2" for: "Flag2" == "Flag2"
+EnumToString.tests.cpp:<line number>: passed: stringify( LargeEnum::Flag5 ) == "Flag5" for: "Flag5" == "Flag5"
EnumToString.tests.cpp:<line number>: passed: stringify( EnumClass3::Value1 ) == "Value1" for: "Value1" == "Value1"
EnumToString.tests.cpp:<line number>: passed: stringify( EnumClass3::Value2 ) == "Value2" for: "Value2" == "Value2"
EnumToString.tests.cpp:<line number>: passed: stringify( EnumClass3::Value3 ) == "Value3" for: "Value3" == "Value3"
@@ -2755,13 +2758,13 @@ Tricky.tests.cpp:<line number>: passed: ptr.get() == 0 for: 0 == 0
ToStringPair.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }"
==
"{ { 42, "Arthur" }, { "Ford", 24 } }"
-ToString.tests.cpp:<line number>: passed: parseEnums( "" ), Equals( std::vector<Catch::StringRef>{} ) for: { } Equals: { }
-ToString.tests.cpp:<line number>: passed: parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) for: { Value1 } Equals: { Value1 }
-ToString.tests.cpp:<line number>: passed: parseEnums( "Value1" ), Equals( std::vector<Catch::StringRef>{"Value1"} ) for: { Value1 } Equals: { Value1 }
-ToString.tests.cpp:<line number>: passed: parseEnums( "EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) for: { Value1 } Equals: { Value1 }
-ToString.tests.cpp:<line number>: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2"} ) for: { Value1, Value2 } Equals: { Value1, Value2 }
-ToString.tests.cpp:<line number>: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) for: { Value1,