From 050cf8d8568f5502e8025064bbbf2063ba9442a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 6 Jun 2026 00:04:04 +0200 Subject: [PATCH] Make tests compatible with BOOST_NO_EXCEPTIONS --- include/boost/container/hub.hpp | 2 +- test/test_hub_api.cpp | 6 +++++- test/test_hub_exception_safety.cpp | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/container/hub.hpp b/include/boost/container/hub.hpp index 5104fc5..74d3b7a 100644 --- a/include/boost/container/hub.hpp +++ b/include/boost/container/hub.hpp @@ -1287,7 +1287,7 @@ public: //! //! Postcondition: capacity() >= n. //! - //! Throws: length_error_t if n > max_size(), plus any exception + //! Throws: if n > max_size(), plus any exception //! thrown by the allocator. //! //! Complexity: Linear in the number of reserved blocks allocated. diff --git a/test/test_hub_api.cpp b/test/test_hub_api.cpp index 0b97e1c..68371f0 100644 --- a/test/test_hub_api.cpp +++ b/test/test_hub_api.cpp @@ -16,6 +16,7 @@ int main() { return 0; } #include #include #include +#include #include #include #include @@ -384,9 +385,12 @@ void test(const typename Hub::allocator_type& al = {}) BOOST_TEST_EQ(cx.capacity(), c); test_equal(x, x2); +#ifndef BOOST_NO_EXCEPTIONS if(cx.max_size() < (size_type)(-1)) { - BOOST_TEST_THROWS(x.reserve(cx.max_size() + 1), std::length_error); + BOOST_TEST_THROWS( + x.reserve(cx.max_size() + 1), boost::container::length_error_t); } +#endif } /* available list partitioned in (non-empty)|(empty) */ diff --git a/test/test_hub_exception_safety.cpp b/test/test_hub_exception_safety.cpp index 0285697..be99148 100644 --- a/test/test_hub_exception_safety.cpp +++ b/test/test_hub_exception_safety.cpp @@ -6,7 +6,11 @@ #include -#if BOOST_CXX_VERSION < 201103L +/* This test exercises exception safety, so it is meaningless (and would not + * even compile, as it relies on try/catch and throw) when exceptions are + * disabled. + */ +#if BOOST_CXX_VERSION < 201103L || defined(BOOST_NO_EXCEPTIONS) int main() { return 0; }