From 4f332cbb9eb62e7c7318c72026380e5073bad40e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 23 Oct 2026 22:17:30 +0200 Subject: [PATCH] Skip the get_to result check without exceptions Without exceptions, the get_to calls in CHECK_THROWS_WITH_AS do not run, so the array keeps its initial values (ci_test_noexceptions). Signed-off-by: Niels Lohmann --- tests/src/unit-constructor1.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/unit-constructor1.cpp b/tests/src/unit-constructor1.cpp index a1778d9e0..4d29ff4d3 100644 --- a/tests/src/unit-constructor1.cpp +++ b/tests/src/unit-constructor1.cpp @@ -369,7 +369,9 @@ TEST_CASE("constructors") std::array a{{0, 0, 0}}; CHECK_THROWS_WITH_AS(j2.get_to(a), "[json.exception.type_error.302] type must be number, but is string", json::type_error&); CHECK_THROWS_WITH_AS(j.get_to(a), "[json.exception.out_of_range.401] array index 1 is out of range", json::out_of_range&); +#if !defined(JSON_NOEXCEPTION) // without exceptions, the get_to calls in CHECK_THROWS_WITH_AS do not run CHECK(a[0] == 1); +#endif json const j3{"one", "two"}; CHECK_THROWS_WITH_AS((j3.get>()), "[json.exception.out_of_range.401] array index 2 is out of range", json::out_of_range&);