Update reserve_tests to handle the space requirements for new FCA implementation

This commit is contained in:
Christian Mazakas
2022-05-20 14:39:54 -07:00
parent a1fb756831
commit 37f5a462e4

View File

@ -1,4 +1,4 @@
// Copyright 2021 Christian Mazakas.
// Copyright 2021-2022 Christian Mazakas.
// 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)
@ -149,9 +149,11 @@ template <class UnorderedContainer> void rehash_tests()
// no reallocations
//
std::size_t prev_allocations = num_allocations;
std::size_t prev_total_allocation = total_allocation;
s.rehash(count);
BOOST_TEST_EQ(num_allocations, prev_allocations);
BOOST_TEST_EQ(total_allocation, prev_total_allocation);
// prove that when we rehash, exceeding the current bucket count, that we
// properly deallocate the current bucket array and then reallocate the
@ -171,8 +173,15 @@ template <class UnorderedContainer> void rehash_tests()
// note, the test is vulnerable to cases where the next calculated bucket
// count can exceed `prev_count + count`
//
std::size_t const estimated_bucket_group_size =
3 * sizeof(void*) + sizeof(std::size_t);
std::size_t const estimated_bucket_groups =
s.bucket_count() / (sizeof(std::size_t) * 8);
BOOST_TEST_LT(s.bucket_count(), prev_count + count);
BOOST_TEST_LT(total_allocation, (prev_count + count) * sizeof(void*));
BOOST_TEST_LE(total_allocation,
(prev_count + count) * sizeof(void*) +
estimated_bucket_group_size * estimated_bucket_groups);
}
BOOST_TEST_GT(num_allocations, 0u);