// (C) Copyright Jeremy Murphy 2015. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #define BOOST_TEST_MAIN #include #include #include #include #include #include #include #include #include #include #include typedef boost::mpl::list signed_integral_test_types; BOOST_AUTO_TEST_CASE_TEMPLATE(test_zero, T, signed_integral_test_types) { T a = boost::math::gcd(static_cast(2), static_cast(0)); BOOST_CHECK_EQUAL(a, static_cast(2)); a = boost::math::gcd(static_cast(0), static_cast(2)); BOOST_CHECK_EQUAL(a, static_cast(2)); } BOOST_AUTO_TEST_CASE_TEMPLATE(test_signed, T, signed_integral_test_types) { T a = boost::math::gcd(static_cast(-40902), static_cast(-24140)); BOOST_CHECK_EQUAL(a, static_cast(34)); a = boost::math::gcd(static_cast(40902), static_cast(24140)); BOOST_CHECK_EQUAL(a, static_cast(34)); } typedef boost::mpl::list unsigned_integral_test_types; BOOST_AUTO_TEST_CASE_TEMPLATE(test_unsigned, T, unsigned_integral_test_types) { T a = boost::math::gcd(static_cast(40902), static_cast(24140)); BOOST_CHECK_EQUAL(a, static_cast(34)); a = boost::math::gcd(static_cast(1836311903), static_cast(2971215073)); // 46th and 47th Fibonacci numbers. 47th is prime. BOOST_CHECK_EQUAL(a, static_cast(1)); }