From 035c58fc5ec7ae1d719b627b2870e28c2407c598 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 8 Jul 2026 16:00:46 +0200 Subject: [PATCH] Fix CI: use CHECK_THROWS_WITH_AS, the macro that actually exists CHECK_THROWS_AS_WITH is not a doctest macro; the correct one used throughout this test suite is CHECK_THROWS_WITH_AS(expr, message, exception_type&), with the message before the type and the type as a reference. The previous commit didn't catch this because it only compiled the file standalone with default settings; this TEST_CASE only compiles under `#if !JSON_USE_IMPLICIT_CONVERSIONS`, which is why ci_test_noimplicitconversions was the job that failed. Verified by building and running the test in that exact configuration (JSON_USE_IMPLICIT_CONVERSIONS=0): 14/14 assertions pass. Signed-off-by: Niels Lohmann --- tests/src/unit-conversions.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/unit-conversions.cpp b/tests/src/unit-conversions.cpp index 298dcdc55..6c36a2451 100644 --- a/tests/src/unit-conversions.cpp +++ b/tests/src/unit-conversions.cpp @@ -1779,10 +1779,10 @@ TEST_CASE("std::optional") // operator); there is no SFINAE path that distinguishes "call from inside // std::optional's constructor" from "direct call". Use get>() // or get_to() instead for correct null handling. See #4864 and #5246. - CHECK_THROWS_AS_WITH(std::optional(j_null), json::type_error, - "type must be string, but is null"); - CHECK_THROWS_AS_WITH(std::optional(j_null), json::type_error, - "type must be number, but is null"); + CHECK_THROWS_WITH_AS(std::optional(j_null), + "[json.exception.type_error.302] type must be string, but is null", json::type_error&); + CHECK_THROWS_WITH_AS(std::optional(j_null), + "[json.exception.type_error.302] type must be number, but is null", json::type_error&); } SECTION("string")