catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Stop compilation if registering an enum could truncate its value
- Commit
4038ee6bc6d9053f5af73cd197d02e47ab624e59- Author
- Martin Hořeňovský ·
- Parents
789f3591ef1f
Changes
include/internal/catch_interfaces_enum_values_registry.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/internal/catch_interfaces_enum_values_registry.h b/include/internal/catch_interfaces_enum_values_registry.h index fea6847d..8e07fc73 100644 --- a/include/internal/catch_interfaces_enum_values_registry.h +++ b/include/internal/catch_interfaces_enum_values_registry.h @@ -32,6 +32,7 @@ namespace Catch { 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 )