From 1300743e9869c13768751462f76b9eaa1239be97 Mon Sep 17 00:00:00 2001 From: FrogTheFrog Date: Wed, 17 Jul 2024 18:04:01 +0300 Subject: [PATCH] formatting --- .../detail/jsonserializerdetails.h | 28 +++++++++---------- .../include/fixtures/jsonconvertertest.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/include/displaydevice/detail/jsonserializerdetails.h b/src/common/include/displaydevice/detail/jsonserializerdetails.h index 02b8f09..df1a465 100644 --- a/src/common/include/displaydevice/detail/jsonserializerdetails.h +++ b/src/common/include/displaydevice/detail/jsonserializerdetails.h @@ -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 & \ - getEnumMap(const Type &) { \ - static_assert(std::is_enum::value, #Type " must be an enum!"); \ - static const std::map map = __VA_ARGS__; \ - return map; \ - } \ - \ - void to_json(nlohmann::json &nlohmann_json_j, const Type &nlohmann_json_t) { \ - nlohmann_json_j = findInEnumMap(#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 " 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 & \ + getEnumMap(const Type &) { \ + static_assert(std::is_enum::value, #Type " must be an enum!"); \ + static const std::map map = __VA_ARGS__; \ + return map; \ + } \ + \ + void to_json(nlohmann::json &nlohmann_json_j, const Type &nlohmann_json_t) { \ + nlohmann_json_j = findInEnumMap(#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 " is missing enum mapping!", [&nlohmann_json_j](const auto &pair) { return pair.second == nlohmann_json_j; })->first; \ } namespace display_device { diff --git a/tests/fixtures/include/fixtures/jsonconvertertest.h b/tests/fixtures/include/fixtures/jsonconvertertest.h index 2358c15..e528781 100644 --- a/tests/fixtures/include/fixtures/jsonconvertertest.h +++ b/tests/fixtures/include/fixtures/jsonconvertertest.h @@ -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;