// Copyright (c) 2006-2018 Maxim Khizhinsky // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include namespace { template class bit_reversal: public ::testing::Test { typedef UInt uint_type; #ifdef CDS_DEBUG static size_t const c_size = 1'000'000; #else static size_t const c_size = 50'000'000; #endif public: template void test() { Algo f; for ( uint_type i = 0; i < c_size; ++i ) { EXPECT_EQ( i, f( f( i ) )); EXPECT_EQ( ~i, f( f( ~i ) )); } } template void test_eq() { Algo f; for ( uint_type i = 0; i < c_size; ++i ) { EXPECT_EQ( cds::algo::bit_reversal::swar()( i ), f( i ) ) << "i=" << i; EXPECT_EQ( cds::algo::bit_reversal::swar()( ~i ), f( ~i ) ) << "~i=" << ~i; } } }; typedef bit_reversal bit_reversal32; typedef bit_reversal bit_reversal64; #define TEST_32BIT( x ) \ TEST_F( bit_reversal32, x ) { test(); } \ TEST_F( bit_reversal32, x##_eq ) { test_eq(); } #define TEST_64BIT( x ) \ TEST_F( bit_reversal64, x ) { test(); } \ TEST_F( bit_reversal64, x##_eq ) { test_eq(); } TEST_32BIT( swar ) TEST_32BIT( lookup ) TEST_32BIT( muldiv ) TEST_64BIT( swar ) TEST_64BIT( lookup ) TEST_64BIT( muldiv ) } // namespace