Make tests compatible with BOOST_NO_EXCEPTIONS

This commit is contained in:
Ion Gaztañaga
2026-06-06 00:04:04 +02:00
parent 55b0e3bdf4
commit 050cf8d856
3 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -1287,7 +1287,7 @@ public:
//!
//! <b>Postcondition</b>: capacity() >= n.
//!
//! <b>Throws</b>: length_error_t if n > max_size(), plus any exception
//! <b>Throws</b>: if n > max_size(), plus any exception
//! thrown by the allocator.
//!
//! <b>Complexity</b>: Linear in the number of reserved blocks allocated.
+5 -1
View File
@@ -16,6 +16,7 @@ int main() { return 0; }
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/container/hub.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/pointer_traits.hpp>
@@ -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) */
+5 -1
View File
@@ -6,7 +6,11 @@
#include <boost/config.hpp>
#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; }