From 50c4cbe06c6a86ad693b686f9b8f969cc8894206 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 2 Oct 2016 13:04:25 +0100 Subject: [PATCH] Try to fix the failures in noxcept_tests --- test/unordered/noexcept_tests.cpp | 65 +++++++++++++++++++------------ 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/test/unordered/noexcept_tests.cpp b/test/unordered/noexcept_tests.cpp index 740602d6..ba31b6e3 100644 --- a/test/unordered/noexcept_tests.cpp +++ b/test/unordered/noexcept_tests.cpp @@ -24,28 +24,6 @@ namespace noexcept_tests 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 >::value)); - BOOST_TEST((boost::is_nothrow_move_constructible< - boost::unordered_multiset >::value)); - BOOST_TEST((boost::is_nothrow_move_constructible< - boost::unordered_map >::value)); - BOOST_TEST((boost::is_nothrow_move_constructible< - boost::unordered_multimap >::value)); -#endif - - BOOST_TEST((!boost::is_nothrow_move_constructible< - boost::unordered_set - >::value)); - BOOST_TEST((!boost::is_nothrow_move_constructible< - boost::unordered_multiset, - equal_to_possible_exception> - >::value)); - } - // Test that the move constructor does actually move without throwing // an exception when it claims to. @@ -97,20 +75,59 @@ namespace noexcept_tests { test_throw("Operator"); return static_cast(*this)(x, y); } }; + bool have_is_nothrow_move = false; + + UNORDERED_AUTO_TEST(check_is_nothrow_move) + { + BOOST_TEST(!boost::is_nothrow_move_constructible::value); + have_is_nothrow_move = boost::is_nothrow_move_constructible::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 >::value)); + BOOST_TEST((boost::is_nothrow_move_constructible< + boost::unordered_multiset >::value)); + BOOST_TEST((boost::is_nothrow_move_constructible< + boost::unordered_map >::value)); + BOOST_TEST((boost::is_nothrow_move_constructible< + boost::unordered_multimap >::value)); + } + + BOOST_TEST((!boost::is_nothrow_move_constructible< + boost::unordered_set + >::value)); + BOOST_TEST((!boost::is_nothrow_move_constructible< + boost::unordered_multiset, + equal_to_possible_exception> + >::value)); + } + UNORDERED_AUTO_TEST(test_no_throw_when_noexcept) { typedef boost::unordered_set throwing_set; - if (boost::is_nothrow_move_constructible::value) + if (have_is_nothrow_move) { + BOOST_TEST(boost::is_nothrow_move_constructible::value); + throwing_test_exception = false; throwing_set x1; x1.insert(10); x1.insert(50); - try { throwing_test_exception = true;