From c145fa1363af6d16f46ddae837ad31924854c286 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 7 Sep 2026 21:03:05 +0200 Subject: [PATCH] Fix clang-tidy findings in the JSON_NO_IO/JSON_THROW_USER test - bugprone-macro-parentheses: wrap the JSON_THROW_USER macro argument in parentheses at the throw site. - modernize-raw-string-literal: switch two escaped JSON string literals to raw string literals. Signed-off-by: Niels Lohmann --- tests/src/unit-no_io_and_user_exceptions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/src/unit-no_io_and_user_exceptions.cpp b/tests/src/unit-no_io_and_user_exceptions.cpp index 63b73d8b3..667d114e7 100644 --- a/tests/src/unit-no_io_and_user_exceptions.cpp +++ b/tests/src/unit-no_io_and_user_exceptions.cpp @@ -31,7 +31,7 @@ // keeps working exactly as it would with the library's own default macros. static int json_throw_user_call_count = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -#define JSON_THROW_USER(exception) do { ++json_throw_user_call_count; throw exception; } while (false) // NOLINT(cppcoreguidelines-macro-usage) +#define JSON_THROW_USER(exception) do { ++json_throw_user_call_count; throw (exception); } while (false) // NOLINT(cppcoreguidelines-macro-usage) #define JSON_TRY_USER try // NOLINT(cppcoreguidelines-macro-usage) #define JSON_CATCH_USER(exception) catch (exception) // NOLINT(cppcoreguidelines-macro-usage) @@ -44,8 +44,8 @@ TEST_CASE("JSON_NO_IO") { // everything that does not touch / must keep working: // parsing from and dumping to std::string - const json j = json::parse("{\"a\":[1,2,3],\"b\":true}"); - CHECK(j.dump() == "{\"a\":[1,2,3],\"b\":true}"); + const json j = json::parse(R"({"a":[1,2,3],"b":true})"); + CHECK(j.dump() == R"({"a":[1,2,3],"b":true})"); CHECK(j.at("a").size() == 3); CHECK(j.at("b").get() == true); }