From a7ecd03f3acd5aedd70a99c163e6aa074032fdb4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 7 Sep 2026 21:02:50 +0200 Subject: [PATCH] Fix clang-tidy raw-string-literal finding and guard a new test against JSON_NOEXCEPTION The issue #5412 whitespace-skipping test added a check_error() helper that relies on catching json::parse_error to verify the exception message; under JSON_NOEXCEPTION, JSON_THROW aborts instead of throwing, which crashed ci_test_noexceptions (and cascaded into the other ci_cmake_options jobs). Guard the whole section with #if !defined(JSON_NOEXCEPTION), matching the existing pattern used by sibling tests in this file. Also switch one escaped string literal to a raw string literal to satisfy clang-tidy's modernize-raw-string-literal check. Signed-off-by: Niels Lohmann --- tests/src/unit-class_parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-class_parser.cpp b/tests/src/unit-class_parser.cpp index b811ee30c..7d86994e1 100644 --- a/tests/src/unit-class_parser.cpp +++ b/tests/src/unit-class_parser.cpp @@ -1486,6 +1486,7 @@ TEST_CASE("parser class") CHECK(accept_helper("\"\\uD80C\\uFFFF\"") == false); } +#if !defined(JSON_NOEXCEPTION) SECTION("issue #5412 - whitespace skipping bookkeeping (compact vs. pretty-printed)") { // lexer::skip_whitespace() reads its first character with get() (to @@ -1545,9 +1546,10 @@ TEST_CASE("parser class") "c": @ })", 70, "[json.exception.parse_error.101] parse error at line 7, column 10: syntax error while parsing value - invalid literal; last read: '\"c\": @'"); - check_error("{\"a\":1,\"b\":[true,false],\"c\":@}", 29, + check_error(R"({"a":1,"b":[true,false],"c":@})", 29, "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing value - invalid literal; last read: '\"c\":@'"); } +#endif SECTION("tests found by mutate++") {