]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/unordered/test/unordered/mix_policy.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / unordered / test / unordered / mix_policy.cpp
1 // Copyright 2022 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
4
5 #include <boost/unordered/detail/implementation.hpp>
6 #include <boost/core/bit.hpp>
7 #include <boost/core/lightweight_test.hpp>
8 #include <boost/cstdint.hpp>
9
10 template<class Policy, class SizeT> void test( SizeT x )
11 {
12 if( x <= 4 )
13 {
14 BOOST_TEST_EQ( Policy::new_bucket_count( x ), 4u );
15 }
16 else
17 {
18 BOOST_TEST_EQ( Policy::new_bucket_count( x ), boost::core::bit_ceil( x ) );
19 }
20
21 BOOST_TEST_EQ( Policy::prev_bucket_count( x ), boost::core::bit_floor( x ) );
22 }
23
24 int main()
25 {
26 {
27 typedef boost::uint64_t SizeT;
28 typedef boost::unordered::detail::mix64_policy<SizeT> policy;
29
30 for( SizeT i = 1; i < 200; ++i )
31 {
32 test<policy>( i );
33 }
34
35 for( int i = 8; i < 64; ++i )
36 {
37 SizeT x = SizeT( 1 ) << i;
38
39 test<policy>( x - 1 );
40 test<policy>( x );
41 test<policy>( x + 1 );
42 }
43 }
44
45 {
46 typedef boost::uint32_t SizeT;
47 typedef boost::unordered::detail::mix32_policy<SizeT> policy;
48
49 for( SizeT i = 1; i < 200; ++i )
50 {
51 test<policy>( i );
52 }
53
54 for( int i = 8; i < 32; ++i )
55 {
56 SizeT x = SizeT( 1 ) << i;
57
58 test<policy>( x - 1 );
59 test<policy>( x );
60 test<policy>( x + 1 );
61 }
62 }
63
64 return boost::report_errors();
65 }