From 8a26f2dc8f6309c05406d5912fe9fdb7d5ba6388 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 26 Sep 2026 07:41:42 +0200 Subject: [PATCH] Skip the failed-allocation test when exceptions are disabled The no-exceptions CI job runs doctest with --no-throw, which skips every CHECK_THROWS_AS. The test then left next_construct_fails set, and the next allocation outside a check threw std::bad_alloc. Signed-off-by: Niels Lohmann --- tests/src/unit-allocator.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 7c32944c1..4e505e9f4 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -389,6 +389,9 @@ TEST_CASE("bad my_allocator::construct") } } +// the no-exceptions CI job skips every CHECK_THROWS_AS, which would leave +// next_construct_fails set for the next allocation outside a check +#if !defined(JSON_NOEXCEPTION) TEST_CASE("a failed allocation leaves the value unchanged") { // create JSON type using the throwing allocator @@ -501,3 +504,4 @@ TEST_CASE("a failed allocation leaves the value unchanged") CHECK(j == my_json({1, 2})); } } +#endif