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 <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-26 07:41:42 +02:00
parent 2c108d0b56
commit 8a26f2dc8f
+4
View File
@@ -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