Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogTheFrog committed Jul 17, 2024
1 parent 3579170 commit 1300743
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/common/include/displaydevice/detail/jsonserializerdetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
// Coverage has trouble with getEnumMap() function since it has a lot of "fallthrough"
// branches when creating a map, therefore the macro has baked in pattern to disable branch coverage
// in GCOVR
#define DD_JSON_DEFINE_SERIALIZE_ENUM_GCOVR_EXCL_BR_LINE(Type, ...) \
const std::map<Type, nlohmann::json> & \
getEnumMap(const Type &) { \
static_assert(std::is_enum<Type>::value, #Type " must be an enum!"); \
static const std::map<Type, nlohmann::json> map = __VA_ARGS__; \
return map; \
} \
\
void to_json(nlohmann::json &nlohmann_json_j, const Type &nlohmann_json_t) { \
nlohmann_json_j = findInEnumMap<Type>(#Type " is missing enum mapping!", [nlohmann_json_t](const auto &pair) { return pair.first == nlohmann_json_t; }) -> second; \
} \
\
void from_json(const nlohmann::json &nlohmann_json_j, Type &nlohmann_json_t) { \
nlohmann_json_t = findInEnumMap<Type>(#Type " is missing enum mapping!", [&nlohmann_json_j](const auto &pair) { return pair.second == nlohmann_json_j; }) -> first; \
#define DD_JSON_DEFINE_SERIALIZE_ENUM_GCOVR_EXCL_BR_LINE(Type, ...) \
const std::map<Type, nlohmann::json> & \
getEnumMap(const Type &) { \
static_assert(std::is_enum<Type>::value, #Type " must be an enum!"); \
static const std::map<Type, nlohmann::json> map = __VA_ARGS__; \
return map; \
} \
\
void to_json(nlohmann::json &nlohmann_json_j, const Type &nlohmann_json_t) { \
nlohmann_json_j = findInEnumMap<Type>(#Type " is missing enum mapping!", [nlohmann_json_t](const auto &pair) { return pair.first == nlohmann_json_t; })->second; \
} \
\
void from_json(const nlohmann::json &nlohmann_json_j, Type &nlohmann_json_t) { \
nlohmann_json_t = findInEnumMap<Type>(#Type " is missing enum mapping!", [&nlohmann_json_j](const auto &pair) { return pair.second == nlohmann_json_j; })->first; \
}

namespace display_device {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/include/fixtures/jsonconvertertest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JsonConverterTest: public BaseTest {
EXPECT_TRUE(success);
EXPECT_EQ(json_string, expected_string);

std::string error_message{};
std::string error_message {};
T defaulted_input {};
if (!display_device::fromJson(json_string, defaulted_input, &error_message)) {
GTEST_FAIL() << error_message;
Expand Down

0 comments on commit 1300743

Please sign in to comment.