From a249c51b55c2c0331b4a23a823617270b19ed36f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 16 Oct 2026 09:05:09 +0200 Subject: [PATCH] Fix the tests for disabled implicit conversions and strict NUL handling - unit-iterators1 (#5835) converted a json element to int implicitly, which does not compile with JSON_USE_IMPLICIT_CONVERSIONS=0. - unit-testsuites parses a number followed by a NUL byte, which JSON_STRICT_NUL_HANDLING rejects; leave the NUL out in strict mode. Signed-off-by: Niels Lohmann --- tests/src/unit-iterators1.cpp | 2 +- tests/src/unit-testsuites.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-iterators1.cpp b/tests/src/unit-iterators1.cpp index 629c6abd7..1fceaf8ff 100644 --- a/tests/src/unit-iterators1.cpp +++ b/tests/src/unit-iterators1.cpp @@ -1661,7 +1661,7 @@ TEST_CASE_TEMPLATE("reverse iteration and member access", Json, nlohmann::json, seen.clear(); for (auto r = j.crbegin(); r != j.crend(); ++r) { - seen.push_back(*r); + seen.push_back(r->template get()); } CHECK(seen == std::vector {4, 3, 2, 1}); } diff --git a/tests/src/unit-testsuites.cpp b/tests/src/unit-testsuites.cpp index 672981967..04df384a8 100644 --- a/tests/src/unit-testsuites.cpp +++ b/tests/src/unit-testsuites.cpp @@ -218,7 +218,11 @@ TEST_CASE("compliance tests from nativejson-benchmark") n1e308[0] = '['; n1e308[1] = '1'; n1e308[310] = ']'; +#if JSON_STRICT_NUL_HANDLING + n1e308.resize(311); // a NUL byte after the value is a syntax error in strict mode +#else n1e308[311] = '\0'; +#endif TEST_DOUBLE(n1e308, 1E308); }