diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e3b5be1..ea29336 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,6 +19,7 @@ test-suite integer [ compile static_log2_include_test.cpp ] [ compile static_min_max_include_test.cpp ] [ compile integer_fwd_include_test.cpp ] + [ compile gcd_constexpr14_test.cpp ] [ compile-fail fail_int_exact.cpp ] [ compile-fail fail_int_fast.cpp ] [ compile-fail fail_int_least.cpp ] diff --git a/test/gcd_constexpr14_test.cpp b/test/gcd_constexpr14_test.cpp new file mode 100644 index 0000000..e915ce8 --- /dev/null +++ b/test/gcd_constexpr14_test.cpp @@ -0,0 +1,42 @@ + +// (C) Copyright John Maddock 2017. +// Distributed under 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 + +#ifndef BOOST_NO_CXX14_CONSTEXPR + +void test_constexpr() +{ + constexpr const boost::int64_t i = 347 * 463 * 727; + constexpr const boost::int64_t j = 191 * 347 * 281; + + constexpr const boost::int64_t k = boost::integer::gcd(i, j); + constexpr const boost::int64_t l = boost::integer::lcm(i, j); + + static_assert(k == 347, "Expected result not found in constexpr gcd."); + static_assert(l == 6268802158037, "Expected result not found in constexpr lcm."); +} + +#endif + +#ifndef BOOST_NO_CXX11_NOEXCEPT + +void test_noexcept() +{ + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + //static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); + static_assert(noexcept(boost::integer::gcd(static_cast(2), static_cast(4))), "Expected a noexcept function."); +} + +#endif