]>
git.proxmox.com Git - ceph.git/blob - 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
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>
10 template<class Policy
, class SizeT
> void test( SizeT x
)
14 BOOST_TEST_EQ( Policy::new_bucket_count( x
), 4u );
18 BOOST_TEST_EQ( Policy::new_bucket_count( x
), boost::core::bit_ceil( x
) );
21 BOOST_TEST_EQ( Policy::prev_bucket_count( x
), boost::core::bit_floor( x
) );
27 typedef boost::uint64_t SizeT
;
28 typedef boost::unordered::detail::mix64_policy
<SizeT
> policy
;
30 for( SizeT i
= 1; i
< 200; ++i
)
35 for( int i
= 8; i
< 64; ++i
)
37 SizeT x
= SizeT( 1 ) << i
;
39 test
<policy
>( x
- 1 );
41 test
<policy
>( x
+ 1 );
46 typedef boost::uint32_t SizeT
;
47 typedef boost::unordered::detail::mix32_policy
<SizeT
> policy
;
49 for( SizeT i
= 1; i
< 200; ++i
)
54 for( int i
= 8; i
< 32; ++i
)
56 SizeT x
= SizeT( 1 ) << i
;
58 test
<policy
>( x
- 1 );
60 test
<policy
>( x
+ 1 );
64 return boost::report_errors();