Skip to content

Commit

Permalink
Make tests robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhruby committed Sep 29, 2024
1 parent b83bfc7 commit 58a1afd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions modules/serdes/include/hephaestus/serdes/protobuf/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ template <EnumType ProtoT, EnumType T>
auto toProtoEnum(const T& enum_value) -> ProtoT {
static const auto enum_to_proto_enum = internal::createEnumLookupTable<ProtoT, T>();
const auto it = enum_to_proto_enum.find(enum_value);
throwExceptionIf<InvalidDataException>(it == enum_to_proto_enum.end(),
"Enum {} not found in the lookup table",
utils::format::toString(enum_value));
throwExceptionIf<InvalidDataException>(
it == enum_to_proto_enum.end(),
fmt::format("Enum {} not found in the lookup table", utils::format::toString(enum_value)));
return it->second;
}

Expand All @@ -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<ProtoT, T>());
const auto it = proto_enum_value_to_enum.find(proto_enum_value);
throwExceptionIf<InvalidDataException>(it == proto_enum_value_to_enum.end(),
"Enum {} not found in the lookup table",
utils::format::toString(proto_enum_value));
throwExceptionIf<InvalidDataException>(
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;
;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/types_proto/tests/serialization_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ TYPED_TEST(SerializationTests, TestSerialization) {
const auto value = random::random<TypeParam>(mt);

TypeParam value_des{};
if constexpr (!std::is_same_v<TypeParam, bool>) { // sample space of bool is too small
if constexpr (!std::is_same_v<TypeParam, bool> || !std::is_same_v<TypeParam, int8_t> ||
!std::is_same_v<TypeParam, uint8_t>) { // sample space of bool is too small
EXPECT_NE(value, value_des);
}

Expand Down

0 comments on commit 58a1afd

Please sign in to comment.