diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index 60e63c6190..ab7bfaa7db 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -1263,7 +1263,7 @@ TEST_CASE("value conversion") } #endif -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION SECTION("get an enum") { enum c_enum { value_1, value_2 }; @@ -1272,7 +1272,7 @@ TEST_CASE("value conversion") CHECK(json(value_1).get() == value_1); CHECK(json(cpp_enum::value_1).get() == cpp_enum::value_1); } -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION SECTION("more involved conversions") { diff --git a/tests/src/unit-noexcept.cpp b/tests/src/unit-noexcept.cpp index 2e7f73bef1..6160a77a83 100644 --- a/tests/src/unit-noexcept.cpp +++ b/tests/src/unit-noexcept.cpp @@ -44,10 +44,10 @@ static_assert(noexcept(std::declval().get()), ""); static_assert(!noexcept(std::declval().get()), ""); static_assert(noexcept(json(pod{})), ""); -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION static_assert(noexcept(nlohmann::to_json(std::declval(), test{})), ""); static_assert(noexcept(json(test{})), ""); -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION } // namespace TEST_CASE("noexcept") diff --git a/tests/src/unit-regression1.cpp b/tests/src/unit-regression1.cpp index bc7affc0be..2ca5800957 100644 --- a/tests/src/unit-regression1.cpp +++ b/tests/src/unit-regression1.cpp @@ -169,7 +169,7 @@ TEST_CASE("regression tests 1") } } -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION SECTION("pull request #71 - handle enum type") { enum { t = 0, u = 102}; @@ -192,7 +192,7 @@ TEST_CASE("regression tests 1") {"game_type", t} })); } -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION SECTION("issue #76 - dump() / parse() not idempotent") { diff --git a/tests/src/unit-udt.cpp b/tests/src/unit-udt.cpp index 69ad0e211c..c725e82b5c 100644 --- a/tests/src/unit-udt.cpp +++ b/tests/src/unit-udt.cpp @@ -130,12 +130,12 @@ static void to_json(nlohmann::json& j, const contact& c) j = json{{"person", c.m_person}, {"address", c.m_address}}; } -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION static void to_json(nlohmann::json& j, const contact_book& cb) { j = json{{"name", cb.m_book_name}, {"id", cb.m_book_id}, {"contacts", cb.m_contacts}}; } -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION // operators static bool operator==(age lhs, age rhs) @@ -221,14 +221,14 @@ static void from_json(const nlohmann::json& j, contact& c) c.m_address = j["address"].get
(); } -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION static void from_json(const nlohmann::json& j, contact_book& cb) { cb.m_book_name = j["name"].get(); cb.m_book_id = j["id"].get(); cb.m_contacts = j["contacts"].get>(); } -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION } // namespace udt TEST_CASE("basic usage" * doctest::test_suite("udt")) @@ -257,7 +257,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) CHECK(json("Paris") == json(addr)); CHECK(json(cpp_programmer) == R"({"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"})"_json); -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION CHECK(json(large_id) == json(static_cast(1) << 63)); CHECK(json(large_id) > 0u); CHECK(to_string(json(large_id)) == "9223372036854775808"); @@ -266,7 +266,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) CHECK( json(book) == R"({"name":"C++", "id":42, "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json); -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION } SECTION("conversion from json via free-functions") @@ -275,11 +275,11 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) R"({"name":"C++", "id":42, "contacts" : [{"person" : {"age":23, "name":"theo", "country":"France"}, "address":"Paris"}, {"person" : {"age":42, "country":"中华人民共和国", "name":"王芳"}, "address":"Paris"}]})"_json; SECTION("via explicit calls to get") { -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION const auto parsed_book = big_json.get(); const auto book_name = big_json["name"].get(); const auto book_id = big_json["id"].get(); -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION const auto contacts = big_json["contacts"].get>(); const auto contact_json = big_json["contacts"].at(0); @@ -298,11 +298,11 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) CHECK(person == sfinae_addict); CHECK(contact == cpp_programmer); CHECK(contacts == book.m_contacts); -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION CHECK(book_name == udt::name{"C++"}); CHECK(book_id == book.m_book_id); CHECK(book == parsed_book); -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION } SECTION("via explicit calls to get_to") @@ -317,7 +317,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) person_json["name"].get_to(name).m_val = "new name"; CHECK(name.m_val == "new name"); } -#if JSON_DISABLE_ENUM_SERIALIZATION != 0 +#if JSON_DISABLE_ENUM_SERIALIZATION #if JSON_USE_IMPLICIT_CONVERSIONS SECTION("implicit conversions") { @@ -347,7 +347,7 @@ TEST_CASE("basic usage" * doctest::test_suite("udt")) CHECK(book == parsed_book); } #endif -#endif +#endif // JSON_DISABLE_ENUM_SERIALIZATION } }