diff --git a/test/endian_arithmetic_test.cpp b/test/endian_arithmetic_test.cpp index 7dfb578..725aac2 100644 --- a/test/endian_arithmetic_test.cpp +++ b/test/endian_arithmetic_test.cpp @@ -9,7 +9,7 @@ #include #include -template void test_( T const& x ) +template void test_arithmetic_( T const& x ) { boost::endian::endian_arithmetic y( x ); @@ -20,14 +20,6 @@ template> 1, y >> 1 ); { T x2( x ); @@ -57,6 +49,48 @@ template y2( y ); + + BOOST_TEST_EQ( ++x2, ++y2 ); + } + + { + T x2( x ); + boost::endian::endian_arithmetic y2( y ); + + BOOST_TEST_EQ( --x2, --y2 ); + } + + { + T x2( x ); + boost::endian::endian_arithmetic y2( y ); + + BOOST_TEST_EQ( x2++, y2++ ); + } + + { + T x2( x ); + boost::endian::endian_arithmetic y2( y ); + + BOOST_TEST_EQ( x2--, y2-- ); + } +} + +template void test_integral_( T const& x ) +{ + boost::endian::endian_arithmetic y( x ); + + BOOST_TEST_EQ( x % x, y % y ); + + BOOST_TEST_EQ( x & x, y & y ); + BOOST_TEST_EQ( x | x, y | y ); + BOOST_TEST_EQ( x ^ x, y ^ y ); + + BOOST_TEST_EQ( x << 1, y << 1 ); + BOOST_TEST_EQ( x >> 1, y >> 1 ); + { T x2( x ); boost::endian::endian_arithmetic y2( y ); @@ -98,48 +132,33 @@ template>= 1, y2 >>= 1 ); } - - { - T x2( x ); - boost::endian::endian_arithmetic y2( y ); - - BOOST_TEST_EQ( ++x2, ++y2 ); - } - - { - T x2( x ); - boost::endian::endian_arithmetic y2( y ); - - BOOST_TEST_EQ( --x2, --y2 ); - } - - { - T x2( x ); - boost::endian::endian_arithmetic y2( y ); - - BOOST_TEST_EQ( x2++, y2++ ); - } - - { - T x2( x ); - boost::endian::endian_arithmetic y2( y ); - - BOOST_TEST_EQ( x2--, y2-- ); - } } -template void test( T const& x ) +template void test_arithmetic( T const& x ) { - test_( x ); - test_( x ); - test_( x ); - test_( x ); + test_arithmetic_( x ); + test_arithmetic_( x ); + test_arithmetic_( x ); + test_arithmetic_( x ); +} + +template void test_integral( T const& x ) +{ + test_arithmetic( x ); + + test_integral_( x ); + test_integral_( x ); + test_integral_( x ); + test_integral_( x ); } int main() { - test( 0x7EF2 ); - test( 0x01020304u ); + test_integral( 0x7EF2 ); + test_integral( 0x01020304u ); + + test_arithmetic( 3.1416f ); + test_arithmetic( 3.14159 ); return boost::report_errors(); }