forked from boostorg/unordered
Add node-based foa containers to noexcept_tests
This commit is contained in:
@ -6,8 +6,8 @@
|
||||
|
||||
#include "../helpers/unordered.hpp"
|
||||
|
||||
#include "../helpers/test.hpp"
|
||||
#include "../helpers/fwd.hpp"
|
||||
#include "../helpers/test.hpp"
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
@ -203,6 +203,10 @@ namespace noexcept_tests {
|
||||
boost::unordered_flat_set<int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_flat_map<int, int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_node_set<int> >::value));
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_node_map<int, int> >::value));
|
||||
#else
|
||||
BOOST_TEST((boost::is_nothrow_move_constructible<
|
||||
boost::unordered_set<int> >::value));
|
||||
@ -222,6 +226,13 @@ namespace noexcept_tests {
|
||||
BOOST_TEST(
|
||||
(!boost::is_nothrow_move_constructible<boost::unordered_flat_set<int,
|
||||
boost::hash<int>, equal_to_possible_exception> >::value));
|
||||
|
||||
BOOST_TEST(
|
||||
(!boost::is_nothrow_move_constructible<
|
||||
boost::unordered_node_set<int, hash_possible_exception> >::value));
|
||||
BOOST_TEST(
|
||||
(!boost::is_nothrow_move_constructible<boost::unordered_node_set<int,
|
||||
boost::hash<int>, equal_to_possible_exception> >::value));
|
||||
#else
|
||||
BOOST_TEST((!boost::is_nothrow_move_constructible<
|
||||
boost::unordered_set<int, hash_possible_exception> >::value));
|
||||
@ -231,31 +242,24 @@ namespace noexcept_tests {
|
||||
#endif
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_nothrow_move_when_noexcept) {
|
||||
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||
typedef boost::unordered_flat_set<int, hash_nothrow_move_construct,
|
||||
equal_to_nothrow_move_construct>
|
||||
throwing_set;
|
||||
#else
|
||||
typedef boost::unordered_set<int, hash_nothrow_move_construct,
|
||||
equal_to_nothrow_move_construct>
|
||||
throwing_set;
|
||||
#endif
|
||||
template <class X> static void test_nothrow_move_when_noexcept(X*)
|
||||
{
|
||||
X throwing_set;
|
||||
|
||||
if (have_is_nothrow_move) {
|
||||
BOOST_TEST(boost::is_nothrow_move_constructible<throwing_set>::value);
|
||||
BOOST_TEST(boost::is_nothrow_move_constructible<X>::value);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
X x1;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
|
||||
try {
|
||||
throwing_test_exception = true;
|
||||
|
||||
throwing_set x2 = boost::move(x1);
|
||||
X x2 = boost::move(x1);
|
||||
BOOST_TEST(x2.size() == 2);
|
||||
BOOST_TEST(*x2.begin() == 10 || *x2.begin() == 50);
|
||||
BOOST_TEST(have_is_nothrow_move);
|
||||
@ -327,24 +331,16 @@ namespace noexcept_tests {
|
||||
}
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST (test_nothrow_swap_when_noexcept) {
|
||||
#if BOOST_UNORDERED_FOA_TESTS
|
||||
typedef boost::unordered_flat_set<int, hash_nothrow_swap,
|
||||
equal_to_nothrow_swap>
|
||||
throwing_set;
|
||||
#else
|
||||
typedef boost::unordered_set<int, hash_nothrow_swap, equal_to_nothrow_swap>
|
||||
throwing_set;
|
||||
#endif
|
||||
|
||||
template <class X> static void test_nothrow_swap_when_noexcept(X*)
|
||||
{
|
||||
if (have_is_nothrow_swap) {
|
||||
BOOST_TEST(boost::is_nothrow_swappable<throwing_set>::value);
|
||||
BOOST_TEST(boost::is_nothrow_swappable<X>::value);
|
||||
}
|
||||
|
||||
throwing_test_exception = false;
|
||||
|
||||
throwing_set x1;
|
||||
throwing_set x2;
|
||||
X x1;
|
||||
X x2;
|
||||
x1.insert(10);
|
||||
x1.insert(50);
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
@ -365,7 +361,7 @@ namespace noexcept_tests {
|
||||
|
||||
throwing_test_exception = false;
|
||||
}
|
||||
}
|
||||
} // namespace noexcept_tests
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
@ -401,6 +397,7 @@ template <class T> class allocator2
|
||||
{
|
||||
BOOST_COPYABLE_AND_MOVABLE(allocator2)
|
||||
allocator2 operator=(BOOST_COPY_ASSIGN_REF(allocator2));
|
||||
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef boost::true_type propagate_on_container_move_assignment;
|
||||
@ -431,21 +428,53 @@ UNORDERED_AUTO_TEST (prelim_allocator_checks) {
|
||||
|
||||
BOOST_TEST(boost::allocator_is_always_equal<allocator2<int> >::type::value);
|
||||
BOOST_TEST(boost::allocator_propagate_on_container_move_assignment<
|
||||
allocator2<int> >::type::value);
|
||||
allocator2<int> >::type::value);
|
||||
}
|
||||
|
||||
using test::default_generator;
|
||||
|
||||
#ifdef BOOST_UNORDERED_FOA_TESTS
|
||||
boost::unordered_flat_set<int, noexcept_tests::hash_nothrow_move_construct,
|
||||
noexcept_tests::equal_to_nothrow_move_construct>* throwing_set;
|
||||
boost::unordered_flat_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap>* throwing_set2;
|
||||
|
||||
boost::unordered_flat_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap, allocator1<int> >* throwing_set_alloc1;
|
||||
|
||||
boost::unordered_flat_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap, allocator2<int> >* throwing_set_alloc2;
|
||||
|
||||
boost::unordered_node_set<int, noexcept_tests::hash_nothrow_move_construct,
|
||||
noexcept_tests::equal_to_nothrow_move_construct>* throwing_node_set;
|
||||
boost::unordered_node_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap>* throwing_node_set2;
|
||||
|
||||
boost::unordered_node_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap, allocator1<int> >*
|
||||
throwing_node_set_alloc1;
|
||||
|
||||
boost::unordered_node_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap, allocator2<int> >*
|
||||
throwing_node_set_alloc2;
|
||||
|
||||
// clang-format off
|
||||
UNORDERED_TEST(
|
||||
test_nothrow_move_when_noexcept, ((throwing_set)(throwing_node_set)))
|
||||
UNORDERED_TEST(
|
||||
test_nothrow_swap_when_noexcept, ((throwing_set2)(throwing_node_set2)))
|
||||
UNORDERED_TEST(test_nothrow_move_assign_when_noexcept,
|
||||
((throwing_set_alloc1)(throwing_set_alloc2))((default_generator)))
|
||||
((throwing_set_alloc1)(throwing_set_alloc2)
|
||||
(throwing_node_set_alloc1)(throwing_node_set_alloc2))(
|
||||
(default_generator)))
|
||||
// clang-format on
|
||||
#else
|
||||
boost::unordered_set<int, noexcept_tests::hash_nothrow_move_construct,
|
||||
noexcept_tests::equal_to_nothrow_move_construct>* throwing_set;
|
||||
|
||||
boost::unordered_set<int, noexcept_tests::hash_nothrow_swap,
|
||||
noexcept_tests::equal_to_nothrow_swap>* throwing_set2;
|
||||
|
||||
boost::unordered_set<int, noexcept_tests::hash_nothrow_move_assign,
|
||||
noexcept_tests::equal_to_nothrow_move_assign, allocator1<int> >*
|
||||
throwing_set_alloc1;
|
||||
@ -454,6 +483,8 @@ boost::unordered_set<int, noexcept_tests::hash_nothrow_move_assign,
|
||||
noexcept_tests::equal_to_nothrow_move_assign, allocator2<int> >*
|
||||
throwing_set_alloc2;
|
||||
|
||||
UNORDERED_TEST(test_nothrow_move_when_noexcept, ((throwing_set)))
|
||||
UNORDERED_TEST(test_nothrow_swap_when_noexcept, ((throwing_set2)))
|
||||
UNORDERED_TEST(test_nothrow_move_assign_when_noexcept,
|
||||
((throwing_set_alloc1)(throwing_set_alloc2))((default_generator)))
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user