From 4f9b05208dcb730356d5bb230c4f508585f4859c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 24 Sep 2026 07:14:08 +0200 Subject: [PATCH] Account for JSON_DIAGNOSTIC_POSITIONS in the ordered_json parent-pointer test The merge_patch() case parses its input, so with JSON_DIAGNOSTIC_POSITIONS the exception message also carries the byte range of the parsed value. Signed-off-by: Niels Lohmann --- tests/src/unit-diagnostics.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/src/unit-diagnostics.cpp b/tests/src/unit-diagnostics.cpp index 2326c2f2a..a6ece08e4 100644 --- a/tests/src/unit-diagnostics.cpp +++ b/tests/src/unit-diagnostics.cpp @@ -430,7 +430,11 @@ TEST_CASE("Regression tests for extended diagnostics") CHECK(j.dump() == R"({"a":{"c":{"c":"s"},"e":"s"}})"); auto const& constJ = j; +#if JSON_DIAGNOSTIC_POSITIONS + CHECK_THROWS_WITH_AS(constJ["a"]["c"]["c"].at(0), "[json.exception.type_error.304] (/a/c/c) (bytes 18-21) cannot use at() with string", ordered_json::type_error); +#else CHECK_THROWS_WITH_AS(constJ["a"]["c"]["c"].at(0), "[json.exception.type_error.304] (/a/c/c) cannot use at() with string", ordered_json::type_error); +#endif ordered_json const copy = j; CHECK(copy == j); }