mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-29 19:07:15 +02:00
Update reserve_tests to handle the space requirements for new FCA implementation
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user