diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 83794b1b..58417c90 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -70,13 +70,11 @@ test-suite unordered [ run unordered/rehash_tests.cpp ] [ run unordered/equality_tests.cpp ] [ run unordered/swap_tests.cpp ] - # [ run unordered/detail_tests.cpp ] [ run unordered/deduction_tests.cpp ] [ run unordered/scoped_allocator.cpp : : : msvc-14.0:no ] [ run unordered/transparent_tests.cpp ] [ run unordered/reserve_tests.cpp ] [ run unordered/contains_tests.cpp ] - # [ run unordered/mix_policy.cpp ] [ run unordered/erase_if.cpp ] [ run unordered/scary_tests.cpp ] diff --git a/test/unordered/detail_tests.cpp b/test/unordered/detail_tests.cpp deleted file mode 100644 index 545c8381..00000000 --- a/test/unordered/detail_tests.cpp +++ /dev/null @@ -1,101 +0,0 @@ - -// Copyright 2017 Daniel James. -// 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) - -// clang-format off -#include "../helpers/prefix.hpp" -#include -#include -#include "../helpers/postfix.hpp" -// clang-format on - -#include "../helpers/test.hpp" -#include - -// Pretty inefficient, but the test is fast enough. -// Might be too slow if we had larger primes? -bool is_prime(std::size_t x) -{ - if (x == 2) { - return true; - } else if (x == 1 || x % 2 == 0) { - return false; - } else { - // y*y <= x had rounding errors, so instead use y <= (x/y). - for (std::size_t y = 3; y <= (x / y); y += 2) { - if (x % y == 0) { - return false; - break; - } - } - - return true; - } -} - -void test_next_prime(std::size_t value) -{ - std::size_t x = boost::unordered::detail::next_prime(value); - BOOST_TEST(is_prime(x)); - BOOST_TEST(x >= value); -} - -void test_prev_prime(std::size_t value) -{ - std::size_t x = boost::unordered::detail::prev_prime(value); - BOOST_TEST(is_prime(x)); - BOOST_TEST(x <= value); - if (x > value) { - BOOST_LIGHTWEIGHT_TEST_OSTREAM << x << "," << value << std::endl; - } -} - -UNORDERED_AUTO_TEST (next_prime_test) { - BOOST_TEST(!is_prime(0)); - BOOST_TEST(!is_prime(1)); - BOOST_TEST(is_prime(2)); - BOOST_TEST(is_prime(3)); - BOOST_TEST(is_prime(13)); - BOOST_TEST(!is_prime(4)); - BOOST_TEST(!is_prime(100)); - - BOOST_TEST(boost::unordered::detail::next_prime(0) > 0); - - // test_prev_prime doesn't work for values less than 17. - // Which should be okay, unless an allocator has a really tiny - // max_size? - const std::size_t min_prime = 17; - - // test_next_prime doesn't work for values greater than this, - // which might be a problem if you've got terrabytes of memory? - // I seriously doubt the container would work well at such sizes - // regardless. - const std::size_t max_prime = 4294967291ul; - - std::size_t i; - - BOOST_TEST(is_prime(min_prime)); - BOOST_TEST(is_prime(max_prime)); - - for (i = 0; i < 10000; ++i) { - if (i < min_prime) { - BOOST_TEST(boost::unordered::detail::prev_prime(i) == min_prime); - } else { - test_prev_prime(i); - } - test_next_prime(i); - } - - std::size_t last = i - 1; - for (; i > last; last = i, i += i / 5) { - if (i > max_prime) { - BOOST_TEST(boost::unordered::detail::next_prime(i) == max_prime); - } else { - test_next_prime(i); - } - test_prev_prime(i); - } -} - -RUN_TESTS() diff --git a/test/unordered/mix_policy.cpp b/test/unordered/mix_policy.cpp deleted file mode 100644 index 57c0445b..00000000 --- a/test/unordered/mix_policy.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2022 Peter Dimov -// Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt - -#include -#include -#include -#include - -template void test( SizeT x ) -{ - if( x <= 4 ) - { - BOOST_TEST_EQ( Policy::new_bucket_count( x ), 4u ); - } - else - { - BOOST_TEST_EQ( Policy::new_bucket_count( x ), boost::core::bit_ceil( x ) ); - } - - BOOST_TEST_EQ( Policy::prev_bucket_count( x ), boost::core::bit_floor( x ) ); -} - -int main() -{ - { - typedef boost::uint64_t SizeT; - typedef boost::unordered::detail::mix64_policy policy; - - for( SizeT i = 1; i < 200; ++i ) - { - test( i ); - } - - for( int i = 8; i < 64; ++i ) - { - SizeT x = SizeT( 1 ) << i; - - test( x - 1 ); - test( x ); - test( x + 1 ); - } - } - - { - typedef boost::uint32_t SizeT; - typedef boost::unordered::detail::mix32_policy policy; - - for( SizeT i = 1; i < 200; ++i ) - { - test( i ); - } - - for( int i = 8; i < 32; ++i ) - { - SizeT x = SizeT( 1 ) << i; - - test( x - 1 ); - test( x ); - test( x + 1 ); - } - } - - return boost::report_errors(); -}