Add node-based foa containers to reserve_tests

This commit is contained in:
Christian Mazakas
2023-01-17 13:45:28 -08:00
parent 6474f3c8d3
commit 58b8b00233

View File

@ -1,4 +1,4 @@
// Copyright 2021-2022 Christian Mazakas. // Copyright 2021-2023 Christian Mazakas.
// Distributed under the Boost Software License, Version 1.0. (See accompanying // Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -45,7 +45,8 @@ template <typename T> struct A
template <class T> int A<T>::count = 0; template <class T> int A<T>::count = 0;
template <class UnorderedContainer> void bucket_count_constructor() template <class UnorderedContainer>
void bucket_count_constructor(UnorderedContainer*)
{ {
BOOST_TEST_EQ(num_allocations, 0u); BOOST_TEST_EQ(num_allocations, 0u);
BOOST_TEST_EQ(total_allocation, 0u); BOOST_TEST_EQ(total_allocation, 0u);
@ -64,7 +65,8 @@ template <class UnorderedContainer> void bucket_count_constructor()
num_allocations = 0; num_allocations = 0;
} }
template <class UnorderedContainer> void range_bucket_constructor() template <class UnorderedContainer>
void range_bucket_constructor(UnorderedContainer*)
{ {
BOOST_TEST_EQ(num_allocations, 0u); BOOST_TEST_EQ(num_allocations, 0u);
BOOST_TEST_EQ(total_allocation, 0u); BOOST_TEST_EQ(total_allocation, 0u);
@ -85,7 +87,7 @@ template <class UnorderedContainer> void range_bucket_constructor()
num_allocations = 0; num_allocations = 0;
} }
template <class UnorderedContainer> void reserve_tests() template <class UnorderedContainer> void reserve_tests(UnorderedContainer*)
{ {
BOOST_TEST_EQ(num_allocations, 0u); BOOST_TEST_EQ(num_allocations, 0u);
BOOST_TEST_EQ(total_allocation, 0u); BOOST_TEST_EQ(total_allocation, 0u);
@ -124,7 +126,7 @@ template <class UnorderedContainer> void reserve_tests()
num_allocations = 0; num_allocations = 0;
} }
template <class UnorderedContainer> void rehash_tests() template <class UnorderedContainer> void rehash_tests(UnorderedContainer*)
{ {
BOOST_TEST_EQ(num_allocations, 0u); BOOST_TEST_EQ(num_allocations, 0u);
BOOST_TEST_EQ(total_allocation, 0u); BOOST_TEST_EQ(total_allocation, 0u);
@ -191,8 +193,7 @@ template <class UnorderedContainer> void rehash_tests()
num_allocations = 0; num_allocations = 0;
} }
UNORDERED_AUTO_TEST (unordered_set_reserve) { UNORDERED_AUTO_TEST (allocator_check) {
{
// prove Allocator invariants // prove Allocator invariants
// from cppref: // from cppref:
// Given: // Given:
@ -217,63 +218,56 @@ UNORDERED_AUTO_TEST (unordered_set_reserve) {
} }
#ifdef BOOST_UNORDERED_FOA_TESTS #ifdef BOOST_UNORDERED_FOA_TESTS
typedef boost::unordered_flat_set<int*, boost::hash<int*>, static boost::unordered_flat_set<int*, boost::hash<int*>, std::equal_to<int*>,
std::equal_to<int*>, A<int*> > A<int*> >* test_set;
unordered_set; static boost::unordered_flat_map<int*, int*, boost::hash<int*>,
std::equal_to<int*>, A<std::pair<int const*, int*> > >* test_map;
typedef boost::unordered_flat_map<int*, int*, boost::hash<int*>, static boost::unordered_node_set<int*, boost::hash<int*>, std::equal_to<int*>,
std::equal_to<int*>, A<std::pair<int const*, int*> > > A<int*> >* test_node_set;
unordered_map;
bucket_count_constructor<unordered_set>(); static boost::unordered_node_map<int*, int*, boost::hash<int*>,
bucket_count_constructor<unordered_map>(); std::equal_to<int*>, A<std::pair<int const*, int*> > >* test_node_map;
range_bucket_constructor<unordered_set>(); // clang-format off
range_bucket_constructor<unordered_map>(); UNORDERED_TEST(bucket_count_constructor,
((test_set)(test_map)(test_node_set)(test_node_map)))
reserve_tests<unordered_set>(); UNORDERED_TEST(range_bucket_constructor,
reserve_tests<unordered_map>(); ((test_set)(test_map)(test_node_set)(test_node_map)))
rehash_tests<unordered_set>(); UNORDERED_TEST(reserve_tests,
rehash_tests<unordered_map>(); ((test_set)(test_map)(test_node_set)(test_node_map)))
UNORDERED_TEST(rehash_tests,
((test_set)(test_map)(test_node_set)(test_node_map)))
// clang-format on
#else #else
typedef boost::unordered_set<int, boost::hash<int>, std::equal_to<int>, static boost::unordered_set<int, boost::hash<int>, std::equal_to<int>, A<int> >*
A<int> > test_set;
unordered_set;
typedef boost::unordered_multiset<int, boost::hash<int>, std::equal_to<int>, static boost::unordered_multiset<int, boost::hash<int>, std::equal_to<int>,
A<int> > A<int> >* test_multiset;
unordered_multiset;
typedef boost::unordered_map<int, int, boost::hash<int>, std::equal_to<int>, static boost::unordered_map<int, int, boost::hash<int>, std::equal_to<int>,
A<std::pair<int const, int> > > A<std::pair<int const, int> > >* test_map;
unordered_map;
typedef boost::unordered_multimap<int, int, boost::hash<int>, static boost::unordered_multimap<int, int, boost::hash<int>, std::equal_to<int>,
std::equal_to<int>, A<std::pair<int const, int> > > A<std::pair<int const, int> > >* test_multimap;
unordered_multimap;
bucket_count_constructor<unordered_set>(); // clang-format off
bucket_count_constructor<unordered_map>(); UNORDERED_TEST(bucket_count_constructor,
bucket_count_constructor<unordered_multiset>(); ((test_set)(test_map)(test_multiset)(test_multimap)))
bucket_count_constructor<unordered_multimap>();
range_bucket_constructor<unordered_set>(); UNORDERED_TEST(range_bucket_constructor,
range_bucket_constructor<unordered_map>(); ((test_set)(test_map)(test_multiset)(test_multimap)))
range_bucket_constructor<unordered_multiset>();
range_bucket_constructor<unordered_multimap>();
reserve_tests<unordered_set>(); UNORDERED_TEST(reserve_tests,
reserve_tests<unordered_map>(); ((test_set)(test_map)(test_multiset)(test_multimap)))
reserve_tests<unordered_multiset>();
reserve_tests<unordered_multimap>();
rehash_tests<unordered_set>(); UNORDERED_TEST(rehash_tests,
rehash_tests<unordered_map>(); ((test_set)(test_map)(test_multiset)(test_multimap)))
rehash_tests<unordered_multiset>(); // clang-format on
rehash_tests<unordered_multimap>();
#endif #endif
}
RUN_TESTS() RUN_TESTS()