| 1 | // Test for boost/core/detail/splitmix64.hpp |
|---|---|
| 2 | // |
| 3 | // Copyright 2022 Peter Dimov |
| 4 | // Distributed under the Boost Software License, Version 1.0. |
| 5 | // https://www.boost.org/LICENSE_1_0.txt |
| 6 | |
| 7 | #include <boost/core/detail/splitmix64.hpp> |
| 8 | #include <boost/core/lightweight_test.hpp> |
| 9 | #include <boost/cstdint.hpp> |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | { |
| 14 | boost::detail::splitmix64 rng; |
| 15 | |
| 16 | boost::uint64_t r1 = rng(), x1 = ( boost::uint64_t(0xe220a839u) << 32 ) + 0x7b1dcdafu; |
| 17 | BOOST_TEST_EQ( r1, x1 ); |
| 18 | |
| 19 | for( int i = 0; i < 1000; ++i ) rng(); |
| 20 | |
| 21 | boost::uint64_t r2 = rng(), x2 = ( boost::uint64_t(0xdcad513cu) << 32 ) + 0x211f942du; |
| 22 | BOOST_TEST_EQ( r2, x2 ); |
| 23 | } |
| 24 | |
| 25 | { |
| 26 | boost::detail::splitmix64 rng( 12345 ); |
| 27 | |
| 28 | boost::uint64_t r1 = rng(), x1 = ( boost::uint64_t(0x22118258u) << 32 ) + 0xa9d111a0u; |
| 29 | BOOST_TEST_EQ( r1, x1 ); |
| 30 | |
| 31 | for( int i = 0; i < 1000; ++i ) rng(); |
| 32 | |
| 33 | boost::uint64_t r2 = rng(), x2 = ( boost::uint64_t(0xaaefb4b6u) << 32 ) + 0x5c15e958u; |
| 34 | BOOST_TEST_EQ( r2, x2 ); |
| 35 | } |
| 36 | |
| 37 | return boost::report_errors(); |
| 38 | } |
| 39 |
