From 58a1afd48784f3b2934ee0130de6f7f6b2ef7417 Mon Sep 17 00:00:00 2001 From: Lorenz Hruby Date: Sun, 29 Sep 2024 15:56:03 +0000 Subject: [PATCH] Make tests robust. --- .../include/hephaestus/serdes/protobuf/enums.h | 12 ++++++------ modules/types_proto/tests/serialization_tests.cpp | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/serdes/include/hephaestus/serdes/protobuf/enums.h b/modules/serdes/include/hephaestus/serdes/protobuf/enums.h index f1401379..588d3039 100644 --- a/modules/serdes/include/hephaestus/serdes/protobuf/enums.h +++ b/modules/serdes/include/hephaestus/serdes/protobuf/enums.h @@ -98,9 +98,9 @@ template auto toProtoEnum(const T& enum_value) -> ProtoT { static const auto enum_to_proto_enum = internal::createEnumLookupTable(); const auto it = enum_to_proto_enum.find(enum_value); - throwExceptionIf(it == enum_to_proto_enum.end(), - "Enum {} not found in the lookup table", - utils::format::toString(enum_value)); + throwExceptionIf( + it == enum_to_proto_enum.end(), + fmt::format("Enum {} not found in the lookup table", utils::format::toString(enum_value))); return it->second; } @@ -109,9 +109,9 @@ auto fromProto(const ProtoT& proto_enum_value, T& enum_value) -> void { static const auto proto_enum_value_to_enum = internal::createInverseLookupTable(internal::createEnumLookupTable()); const auto it = proto_enum_value_to_enum.find(proto_enum_value); - throwExceptionIf(it == proto_enum_value_to_enum.end(), - "Enum {} not found in the lookup table", - utils::format::toString(proto_enum_value)); + throwExceptionIf( + it == proto_enum_value_to_enum.end(), + fmt::format("Enum {} not found in the lookup table", utils::format::toString(proto_enum_value))); enum_value = it->second; ; } diff --git a/modules/types_proto/tests/serialization_tests.cpp b/modules/types_proto/tests/serialization_tests.cpp index acbe9e8e..a1b1d0d1 100644 --- a/modules/types_proto/tests/serialization_tests.cpp +++ b/modules/types_proto/tests/serialization_tests.cpp @@ -46,7 +46,8 @@ TYPED_TEST(SerializationTests, TestSerialization) { const auto value = random::random(mt); TypeParam value_des{}; - if constexpr (!std::is_same_v) { // sample space of bool is too small + if constexpr (!std::is_same_v || !std::is_same_v || + !std::is_same_v) { // sample space of bool is too small EXPECT_NE(value, value_des); }