From ae2182cce1f1297141c41efd574ff73a03e76c43 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 8 Jul 2026 17:03:46 +0200 Subject: [PATCH] Run std::optional test under default implicit-conversions build too TEST_CASE("std::optional") was guarded by #if !JSON_USE_IMPLICIT_CONVERSIONS, so it only ever compiled in the non-default build with implicit conversions disabled. This traces back to commit 1d7688aef (fixes #3859), which changed a previously dead #ifndef JSON_USE_IMPLICIT_CONVERSIONS guard (the macro is always defined by that point, so it never held) to #if !JSON_USE_IMPLICIT_CONVERSIONS -- making the test compile for the first time, but only in the disabled-conversions build. As a result, std::optional support had zero test coverage in the default configuration almost every user builds with. Verified the entire test case (all sections: null, string, bool, number, array, object) compiles and passes identically with JSON_USE_IMPLICIT_CONVERSIONS both on (default) and off -- nothing in it actually depends on the setting. Removing the guard closes the coverage gap with no behavior change: 285 assertions pass with implicit conversions on, 232 with them off (the difference comes from other, unrelated conditionally-compiled tests in this file). Signed-off-by: Niels Lohmann --- tests/src/unit-conversions.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index 6c36a2451..b3ab6a8f1 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -1761,7 +1761,6 @@ TEST_CASE("std::filesystem::path") } #endif -#if !JSON_USE_IMPLICIT_CONVERSIONS TEST_CASE("std::optional") { SECTION("null") @@ -1831,7 +1830,6 @@ TEST_CASE("std::optional") } } #endif -#endif #ifdef JSON_HAS_CPP_17 #undef JSON_HAS_CPP_17