diff --git a/tests/robin_map_tests.cpp b/tests/robin_map_tests.cpp index 2a9a8ab..d8898da 100644 --- a/tests/robin_map_tests.cpp +++ b/tests/robin_map_tests.cpp @@ -745,41 +745,44 @@ BOOST_AUTO_TEST_CASE(test_modify_value_through_iterator_with_const_qualifier) { /** * constructor */ + BOOST_AUTO_TEST_CASE(test_extreme_bucket_count_value_construction) { - TSL_RH_CHECK_THROW( + // std::bad_alloc or std::length_error will be thrown depending on the + // platform overcommit + TSL_RH_CHECK_THROW_EITHER( (tsl::robin_map, std::equal_to, std::allocator>, false, tsl::rh::power_of_two_growth_policy<2>>( std::numeric_limits::max())), - std::length_error); + std::bad_alloc, std::length_error); - TSL_RH_CHECK_THROW( + TSL_RH_CHECK_THROW_EITHER( (tsl::robin_map, std::equal_to, std::allocator>, false, tsl::rh::power_of_two_growth_policy<2>>( std::numeric_limits::max() / 2 + 1)), - std::length_error); + std::bad_alloc, std::length_error); - TSL_RH_CHECK_THROW( + TSL_RH_CHECK_THROW_EITHER( (tsl::robin_map, std::equal_to, std::allocator>, false, tsl::rh::prime_growth_policy>( std::numeric_limits::max())), - std::length_error); + std::bad_alloc, std::length_error); - TSL_RH_CHECK_THROW( + TSL_RH_CHECK_THROW_EITHER( (tsl::robin_map, std::equal_to, std::allocator>, false, tsl::rh::prime_growth_policy>( std::numeric_limits::max() / 2)), - std::length_error); + std::bad_alloc, std::length_error); - TSL_RH_CHECK_THROW( + TSL_RH_CHECK_THROW_EITHER( (tsl::robin_map, std::equal_to, std::allocator>, false, tsl::rh::mod_growth_policy<>>( std::numeric_limits::max())), - std::length_error); + std::bad_alloc, std::length_error); } BOOST_AUTO_TEST_CASE(test_range_construct) { diff --git a/tests/utils.h b/tests/utils.h index 697066f..74433a3 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -36,8 +36,18 @@ #ifdef TSL_RH_NO_EXCEPTIONS #define TSL_RH_CHECK_THROW(S, E) +#define TSL_RH_CHECK_THROW_EITHER(S, E1, E2) #else #define TSL_RH_CHECK_THROW(S, E) BOOST_CHECK_THROW(S, E) +#define TSL_RH_CHECK_THROW_EITHER(S, E1, E2) \ + do { \ + try { \ + S; \ + BOOST_CHECK(false); \ + } catch (const E1&) { \ + } catch (const E2&) { \ + } \ + } while (0) #endif template