mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 11:57:15 +02:00
Try to fix the failures in noxcept_tests
This commit is contained in:
@ -24,28 +24,6 @@ namespace noexcept_tests
|
|||||||
equal_to_possible_exception(equal_to_possible_exception const&) {}
|
equal_to_possible_exception(equal_to_possible_exception const&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST(test_noexcept)
|
|
||||||
{
|
|
||||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
|
|
||||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_set<int> >::value));
|
|
||||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_multiset<int> >::value));
|
|
||||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_map<int, int> >::value));
|
|
||||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_multimap<int, int> >::value));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_set<int, hash_possible_exception>
|
|
||||||
>::value));
|
|
||||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
|
||||||
boost::unordered_multiset<int, boost::hash<int>,
|
|
||||||
equal_to_possible_exception>
|
|
||||||
>::value));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test that the move constructor does actually move without throwing
|
// Test that the move constructor does actually move without throwing
|
||||||
// an exception when it claims to.
|
// an exception when it claims to.
|
||||||
|
|
||||||
@ -97,20 +75,59 @@ namespace noexcept_tests
|
|||||||
{ test_throw("Operator"); return static_cast<base const&>(*this)(x, y); }
|
{ test_throw("Operator"); return static_cast<base const&>(*this)(x, y); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool have_is_nothrow_move = false;
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(check_is_nothrow_move)
|
||||||
|
{
|
||||||
|
BOOST_TEST(!boost::is_nothrow_move_constructible<hash_possible_exception>::value);
|
||||||
|
have_is_nothrow_move = boost::is_nothrow_move_constructible<hash_nothrow_move>::value;
|
||||||
|
|
||||||
|
// Copied from boost::is_nothrow_move_constructible implementation
|
||||||
|
// to make sure this does actually detect it when expected.
|
||||||
|
#ifdef BOOST_IS_NOTHROW_MOVE_CONSTRUCT
|
||||||
|
BOOST_TEST(have_is_nothrow_move);
|
||||||
|
#elif !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
|
||||||
|
BOOST_TEST(have_is_nothrow_move);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
UNORDERED_AUTO_TEST(test_noexcept)
|
||||||
|
{
|
||||||
|
if (have_is_nothrow_move) {
|
||||||
|
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_set<int> >::value));
|
||||||
|
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_multiset<int> >::value));
|
||||||
|
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_map<int, int> >::value));
|
||||||
|
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_multimap<int, int> >::value));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_set<int, hash_possible_exception>
|
||||||
|
>::value));
|
||||||
|
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||||
|
boost::unordered_multiset<int, boost::hash<int>,
|
||||||
|
equal_to_possible_exception>
|
||||||
|
>::value));
|
||||||
|
}
|
||||||
|
|
||||||
UNORDERED_AUTO_TEST(test_no_throw_when_noexcept)
|
UNORDERED_AUTO_TEST(test_no_throw_when_noexcept)
|
||||||
{
|
{
|
||||||
typedef boost::unordered_set<int,
|
typedef boost::unordered_set<int,
|
||||||
hash_nothrow_move, equal_to_nothrow_move> throwing_set;
|
hash_nothrow_move, equal_to_nothrow_move> throwing_set;
|
||||||
|
|
||||||
if (boost::is_nothrow_move_constructible<throwing_set>::value)
|
if (have_is_nothrow_move)
|
||||||
{
|
{
|
||||||
|
BOOST_TEST(boost::is_nothrow_move_constructible<throwing_set>::value);
|
||||||
|
|
||||||
throwing_test_exception = false;
|
throwing_test_exception = false;
|
||||||
|
|
||||||
throwing_set x1;
|
throwing_set x1;
|
||||||
x1.insert(10);
|
x1.insert(10);
|
||||||
x1.insert(50);
|
x1.insert(50);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
throwing_test_exception = true;
|
throwing_test_exception = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user