From d711ce23df7f17e38dd218a91fa3dd905c91f881 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 1 Jun 2015 18:11:11 +0100 Subject: [PATCH] Fix mixed mode comparison operators. See https://svn.boost.org/trac/boost/ticket/11328. And added tests for mixed mode comparisons and other operators. --- .../multiprecision/detail/number_compare.hpp | 60 +++--- .../multiprecision/traits/is_backend.hpp | 62 ++++++ test/Jamfile.v2 | 9 + test/test_mixed.hpp | 191 ++++++++++++++++++ test/test_mixed_cpp_bin_float.cpp | 33 +++ test/test_mixed_cpp_dec_float.cpp | 33 +++ test/test_mixed_mpf_float.cpp | 33 +++ test/test_mixed_mpfr_float.cpp | 33 +++ 8 files changed, 424 insertions(+), 30 deletions(-) create mode 100644 include/boost/multiprecision/traits/is_backend.hpp create mode 100644 test/test_mixed.hpp create mode 100644 test/test_mixed_cpp_bin_float.cpp create mode 100644 test/test_mixed_cpp_dec_float.cpp create mode 100644 test/test_mixed_mpf_float.cpp create mode 100644 test/test_mixed_mpfr_float.cpp diff --git a/include/boost/multiprecision/detail/number_compare.hpp b/include/boost/multiprecision/detail/number_compare.hpp index bddbf4a1b..3ac34b792 100644 --- a/include/boost/multiprecision/detail/number_compare.hpp +++ b/include/boost/multiprecision/detail/number_compare.hpp @@ -6,6 +6,8 @@ #ifndef BOOST_MP_COMPARE_HPP #define BOOST_MP_COMPARE_HPP +#include + // // Comparison operators for number. // @@ -19,56 +21,54 @@ inline bool eval_eq(const B& a, const B& b) { return a.compare(b) == 0; } -// -// For the default version which compares to some arbitrary type convertible to -// our number type, we don't know what value the ExpressionTemplates parameter to -// class number should be. We generally prefer ExpressionTemplates to be enabled -// in case type A is itself an expression template, but we need to test both options -// with is_convertible in case A has an implicit conversion operator to number. -// This is the case with many uBlas types for example. -// -template -inline bool eval_eq(const B& a, const A& b) -{ - typedef typename mpl::if_c< - is_convertible >::value, - number, - number >::type mp_type; - mp_type t(b); +template +inline typename enable_if_c::value, bool>::type eval_eq(const T& a, const U& b) +{ + typename boost::multiprecision::detail::number_from_backend::type t(b); return eval_eq(a, t.backend()); } +template +inline typename enable_if_c::value, bool>::type eval_eq(const T& a, const U& b) +{ + typename boost::multiprecision::detail::number_from_backend::type t(a); + return eval_eq(t.backend(), b); +} template inline bool eval_lt(const B& a, const B& b) { return a.compare(b) < 0; } -template -inline bool eval_lt(const B& a, const A& b) +template +inline typename enable_if_c::value, bool>::type eval_lt(const T& a, const U& b) { - typedef typename mpl::if_c< - is_convertible >::value, - number, - number >::type mp_type; - mp_type t(b); + typename boost::multiprecision::detail::number_from_backend::type t(b); return eval_lt(a, t.backend()); } +template +inline typename enable_if_c::value, bool>::type eval_lt(const T& a, const U& b) +{ + typename boost::multiprecision::detail::number_from_backend::type t(a); + return eval_lt(t.backend(), b); +} template inline bool eval_gt(const B& a, const B& b) { return a.compare(b) > 0; } -template -inline bool eval_gt(const B& a, const A& b) +template +inline typename enable_if_c::value, bool>::type eval_gt(const T& a, const U& b) { - typedef typename mpl::if_c< - is_convertible >::value, - number, - number >::type mp_type; - mp_type t(b); + typename boost::multiprecision::detail::number_from_backend::type t(b); return eval_gt(a, t.backend()); } +template +inline typename enable_if_c::value, bool>::type eval_gt(const T& a, const U& b) +{ + typename boost::multiprecision::detail::number_from_backend::type t(a); + return eval_gt(t.backend(), b); +} } // namespace default_ops diff --git a/include/boost/multiprecision/traits/is_backend.hpp b/include/boost/multiprecision/traits/is_backend.hpp new file mode 100644 index 000000000..bd9458c90 --- /dev/null +++ b/include/boost/multiprecision/traits/is_backend.hpp @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#ifndef BOOST_MP_IS_BACKEND_HPP +#define BOOST_MP_IS_BACKEND_HPP + +#include +#include +#include + +namespace boost{ namespace multiprecision{ namespace detail{ + + BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types); + BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types); + BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types); + + template + struct is_backend + { + static const bool value = has_signed_types::value && has_unsigned_types::value && has_float_types::value; + }; + + template + struct other_backend + { + typedef typename boost::conditional< + boost::is_same, number >::value, + number, number >::type type; + }; + + template + struct number_from_backend + { + typedef typename boost::conditional < + boost::is_convertible >::value, + number, + typename other_backend::type > ::type type; + }; + + template + struct is_first_backend_imp{ static const bool value = false; }; + template + struct is_first_backend_imp{ static const bool value = is_convertible >::value || is_convertible >::value; }; + + template + struct is_first_backend : is_first_backend_imp::value, T, U> {}; + + template + struct is_second_backend_imp{ static const bool value = false; }; + template + struct is_second_backend_imp{ static const bool value = is_convertible >::value || is_convertible >::value; }; + + template + struct is_second_backend : is_second_backend_imp::value, T, U> {}; + +} +} +} + +#endif // BOOST_MP_IS_BACKEND_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7cbb10b11..fd6ce7c49 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -670,6 +670,15 @@ run test_float128_serial.cpp ../../serialization/build//boost_serialization quad run test_cpp_bin_float_serial.cpp ../../serialization/build//boost_serialization : : : release TEST1 : test_bin_dec_float_serial_1 ; run test_cpp_bin_float_serial.cpp ../../serialization/build//boost_serialization : : : release TEST2 : test_bin_dec_float_serial_2 ; +# +# Mixed mode comparison tests, see: https://svn.boost.org/trac/boost/ticket/11328 +# +run test_checked_mixed_cpp_int.cpp ; +run test_mixed_cpp_bin_float.cpp ; +run test_mixed_cpp_dec_float.cpp ; +run test_mixed_mpf_float.cpp gmp : : : [ check-target-builds ../config//has_gmp : : no ] ; +run test_mixed_mpfr_float.cpp mpfr gmp : : : [ check-target-builds ../config//has_mpfr : : no ] ; + if $(enable-specfun) { diff --git a/test/test_mixed.hpp b/test/test_mixed.hpp new file mode 100644 index 000000000..d6a497cdc --- /dev/null +++ b/test/test_mixed.hpp @@ -0,0 +1,191 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. 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) + +#ifndef BOOST_MATH_TEST_MIXED_HPP +#define BOOST_MATH_TEST_MIXED_HPP + +#include "test.hpp" + +template +void test() +{ + Big big_val = 1; + big_val += std::numeric_limits::epsilon(); + Small small_val = 1; + + BOOST_CHECK_EQUAL(big_val == small_val, false); + BOOST_CHECK_EQUAL(big_val <= small_val, false); + BOOST_CHECK_EQUAL(big_val >= small_val, true); + BOOST_CHECK_EQUAL(big_val < small_val, false); + BOOST_CHECK_EQUAL(big_val > small_val, true); + BOOST_CHECK_EQUAL(big_val != small_val, true); + BOOST_CHECK_EQUAL(small_val == big_val, false); + BOOST_CHECK_EQUAL(small_val <= big_val, true); + BOOST_CHECK_EQUAL(small_val >= big_val, false); + BOOST_CHECK_EQUAL(small_val < big_val, true); + BOOST_CHECK_EQUAL(small_val > big_val, false); + BOOST_CHECK_EQUAL(small_val != big_val, true); + // Again with expression templates, on one the other, or both args: + BOOST_CHECK_EQUAL(big_val == small_val * 1, false); + BOOST_CHECK_EQUAL(big_val <= small_val * 1, false); + BOOST_CHECK_EQUAL(big_val >= small_val * 1, true); + BOOST_CHECK_EQUAL(big_val < small_val * 1, false); + BOOST_CHECK_EQUAL(big_val > small_val * 1, true); + BOOST_CHECK_EQUAL(big_val != small_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 == big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 <= big_val, true); + BOOST_CHECK_EQUAL(small_val * 1 >= big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 < big_val, true); + BOOST_CHECK_EQUAL(small_val * 1 > big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 != big_val, true); + BOOST_CHECK_EQUAL(big_val * 1 == small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 <= small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 >= small_val, true); + BOOST_CHECK_EQUAL(big_val * 1 < small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 > small_val, true); + BOOST_CHECK_EQUAL(big_val * 1 != small_val, true); + BOOST_CHECK_EQUAL(small_val == big_val * 1, false); + BOOST_CHECK_EQUAL(small_val <= big_val * 1, true); + BOOST_CHECK_EQUAL(small_val >= big_val * 1, false); + BOOST_CHECK_EQUAL(small_val < big_val * 1, true); + BOOST_CHECK_EQUAL(small_val > big_val * 1, false); + BOOST_CHECK_EQUAL(small_val != big_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 == small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 <= small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 >= small_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 < small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 > small_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 != small_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 == big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 <= big_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 >= big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 < big_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 > big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 != big_val * 1, true); + + + BOOST_CHECK_EQUAL(small_val + big_val, Big(small_val) + big_val); + BOOST_CHECK_EQUAL(small_val - big_val, Big(small_val) - big_val); + BOOST_CHECK_EQUAL(small_val * big_val, Big(small_val) * big_val); + BOOST_CHECK_EQUAL(small_val / big_val, Big(small_val) / big_val); + BOOST_CHECK_EQUAL(big_val + small_val, big_val + Big(small_val)); + BOOST_CHECK_EQUAL(big_val - small_val, big_val - Big(small_val)); + BOOST_CHECK_EQUAL(big_val * small_val, big_val * Big(small_val)); + BOOST_CHECK_EQUAL(big_val / small_val, big_val / Big(small_val)); + // Again with expression templates, on one the other, or both args: + BOOST_CHECK_EQUAL(small_val + (big_val * 1), Big(small_val) + (big_val * 1)); + BOOST_CHECK_EQUAL(small_val - (big_val * 1), Big(small_val) - (big_val * 1)); + BOOST_CHECK_EQUAL(small_val * (big_val * 1), Big(small_val) * (big_val * 1)); + BOOST_CHECK_EQUAL(small_val / (big_val * 1), Big(small_val) / (big_val * 1)); + BOOST_CHECK_EQUAL((big_val * 1) + small_val, (big_val * 1) + Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) - small_val, (big_val * 1) - Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) * small_val, (big_val * 1) * Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) / small_val, (big_val * 1) / Big(small_val)); + BOOST_CHECK_EQUAL((small_val * 1) + big_val, Big((small_val * 1)) + big_val); + BOOST_CHECK_EQUAL((small_val * 1) - big_val, Big((small_val * 1)) - big_val); + BOOST_CHECK_EQUAL((small_val * 1) * big_val, Big((small_val * 1)) * big_val); + BOOST_CHECK_EQUAL((small_val * 1) / big_val, Big((small_val * 1)) / big_val); + BOOST_CHECK_EQUAL(big_val + (small_val * 1), big_val + Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val - (small_val * 1), big_val - Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val * (small_val * 1), big_val * Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val / (small_val * 1), big_val / Big((small_val * 1))); + BOOST_CHECK_EQUAL((small_val * 1) + (big_val * 1), Big((small_val * 1)) + (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) - (big_val * 1), Big((small_val * 1)) - (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) * (big_val * 1), Big((small_val * 1)) * (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) / (big_val * 1), Big((small_val * 1)) / (big_val * 1)); + BOOST_CHECK_EQUAL((big_val * 1) + (small_val * 1), (big_val * 1) + Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) - (small_val * 1), (big_val * 1) - Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) * (small_val * 1), (big_val * 1) * Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) / (small_val * 1), (big_val * 1) / Big((small_val * 1))); + + big_val = 1; + big_val -= std::numeric_limits::epsilon(); + + BOOST_CHECK_EQUAL(big_val == small_val, false); + BOOST_CHECK_EQUAL(big_val <= small_val, true); + BOOST_CHECK_EQUAL(big_val >= small_val, false); + BOOST_CHECK_EQUAL(big_val < small_val, true); + BOOST_CHECK_EQUAL(big_val > small_val, false); + BOOST_CHECK_EQUAL(big_val != small_val, true); + BOOST_CHECK_EQUAL(small_val == big_val, false); + BOOST_CHECK_EQUAL(small_val <= big_val, false); + BOOST_CHECK_EQUAL(small_val >= big_val, true); + BOOST_CHECK_EQUAL(small_val < big_val, false); + BOOST_CHECK_EQUAL(small_val > big_val, true); + BOOST_CHECK_EQUAL(small_val != big_val, true); + // Again with expression templates, on one the other, or both args: + BOOST_CHECK_EQUAL(big_val == small_val * 1, false); + BOOST_CHECK_EQUAL(big_val <= small_val * 1, true); + BOOST_CHECK_EQUAL(big_val >= small_val * 1, false); + BOOST_CHECK_EQUAL(big_val < small_val * 1, true); + BOOST_CHECK_EQUAL(big_val > small_val * 1, false); + BOOST_CHECK_EQUAL(big_val != small_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 == big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 <= big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 >= big_val, true); + BOOST_CHECK_EQUAL(small_val * 1 < big_val, false); + BOOST_CHECK_EQUAL(small_val * 1 > big_val, true); + BOOST_CHECK_EQUAL(small_val * 1 != big_val, true); + BOOST_CHECK_EQUAL(big_val * 1 == small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 <= small_val, true); + BOOST_CHECK_EQUAL(big_val * 1 >= small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 < small_val, true); + BOOST_CHECK_EQUAL(big_val * 1 > small_val, false); + BOOST_CHECK_EQUAL(big_val * 1 != small_val, true); + BOOST_CHECK_EQUAL(small_val == big_val * 1, false); + BOOST_CHECK_EQUAL(small_val <= big_val * 1, false); + BOOST_CHECK_EQUAL(small_val >= big_val * 1, true); + BOOST_CHECK_EQUAL(small_val < big_val * 1, false); + BOOST_CHECK_EQUAL(small_val > big_val * 1, true); + BOOST_CHECK_EQUAL(small_val != big_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 == small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 <= small_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 >= small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 < small_val * 1, true); + BOOST_CHECK_EQUAL(big_val * 1 > small_val * 1, false); + BOOST_CHECK_EQUAL(big_val * 1 != small_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 == big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 <= big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 >= big_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 < big_val * 1, false); + BOOST_CHECK_EQUAL(small_val * 1 > big_val * 1, true); + BOOST_CHECK_EQUAL(small_val * 1 != big_val * 1, true); + + BOOST_CHECK_EQUAL(small_val + big_val, Big(small_val) + big_val); + BOOST_CHECK_EQUAL(small_val - big_val, Big(small_val) - big_val); + BOOST_CHECK_EQUAL(small_val * big_val, Big(small_val) * big_val); + BOOST_CHECK_EQUAL(small_val / big_val, Big(small_val) / big_val); + BOOST_CHECK_EQUAL(big_val + small_val, big_val + Big(small_val)); + BOOST_CHECK_EQUAL(big_val - small_val, big_val - Big(small_val)); + BOOST_CHECK_EQUAL(big_val * small_val, big_val * Big(small_val)); + BOOST_CHECK_EQUAL(big_val / small_val, big_val / Big(small_val)); + // Again with expression templates, on one the other, or both args: + BOOST_CHECK_EQUAL(small_val + (big_val * 1), Big(small_val) + (big_val * 1)); + BOOST_CHECK_EQUAL(small_val - (big_val * 1), Big(small_val) - (big_val * 1)); + BOOST_CHECK_EQUAL(small_val * (big_val * 1), Big(small_val) * (big_val * 1)); + BOOST_CHECK_EQUAL(small_val / (big_val * 1), Big(small_val) / (big_val * 1)); + BOOST_CHECK_EQUAL((big_val * 1) + small_val, (big_val * 1) + Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) - small_val, (big_val * 1) - Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) * small_val, (big_val * 1) * Big(small_val)); + BOOST_CHECK_EQUAL((big_val * 1) / small_val, (big_val * 1) / Big(small_val)); + BOOST_CHECK_EQUAL((small_val * 1) + big_val, Big((small_val * 1)) + big_val); + BOOST_CHECK_EQUAL((small_val * 1) - big_val, Big((small_val * 1)) - big_val); + BOOST_CHECK_EQUAL((small_val * 1) * big_val, Big((small_val * 1)) * big_val); + BOOST_CHECK_EQUAL((small_val * 1) / big_val, Big((small_val * 1)) / big_val); + BOOST_CHECK_EQUAL(big_val + (small_val * 1), big_val + Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val - (small_val * 1), big_val - Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val * (small_val * 1), big_val * Big((small_val * 1))); + BOOST_CHECK_EQUAL(big_val / (small_val * 1), big_val / Big((small_val * 1))); + BOOST_CHECK_EQUAL((small_val * 1) + (big_val * 1), Big((small_val * 1)) + (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) - (big_val * 1), Big((small_val * 1)) - (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) * (big_val * 1), Big((small_val * 1)) * (big_val * 1)); + BOOST_CHECK_EQUAL((small_val * 1) / (big_val * 1), Big((small_val * 1)) / (big_val * 1)); + BOOST_CHECK_EQUAL((big_val * 1) + (small_val * 1), (big_val * 1) + Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) - (small_val * 1), (big_val * 1) - Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) * (small_val * 1), (big_val * 1) * Big((small_val * 1))); + BOOST_CHECK_EQUAL((big_val * 1) / (small_val * 1), (big_val * 1) / Big((small_val * 1))); +} + +#endif // BOOST_MATH_TEST_MIXED_HPP diff --git a/test/test_mixed_cpp_bin_float.cpp b/test/test_mixed_cpp_bin_float.cpp new file mode 100644 index 000000000..3ec03df0b --- /dev/null +++ b/test/test_mixed_cpp_bin_float.cpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. 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_ + +#ifdef _MSC_VER +# define _SCL_SECURE_NO_WARNINGS +#endif + +#include +#include "test_mixed.hpp" + +int main() +{ + try{ + typedef boost::multiprecision::number, boost::multiprecision::et_on> big_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_on> small_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_off> big_type2; + typedef boost::multiprecision::number, boost::multiprecision::et_off> small_type2; + + test(); + test(); + test(); + test(); + } + catch(const std::exception& e) + { + std::cout << "Failed with unexpected exception: " << e.what() << std::endl; + return 1; + } + return boost::report_errors(); +} + diff --git a/test/test_mixed_cpp_dec_float.cpp b/test/test_mixed_cpp_dec_float.cpp new file mode 100644 index 000000000..6582630e1 --- /dev/null +++ b/test/test_mixed_cpp_dec_float.cpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. 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_ + +#ifdef _MSC_VER +# define _SCL_SECURE_NO_WARNINGS +#endif + +#include +#include "test_mixed.hpp" + +int main() +{ + try{ + typedef boost::multiprecision::number, boost::multiprecision::et_on> big_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_on> small_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_off> big_type2; + typedef boost::multiprecision::number, boost::multiprecision::et_off> small_type2; + + test(); + test(); + test(); + test(); + } + catch(const std::exception& e) + { + std::cout << "Failed with unexpected exception: " << e.what() << std::endl; + return 1; + } + return boost::report_errors(); +} + diff --git a/test/test_mixed_mpf_float.cpp b/test/test_mixed_mpf_float.cpp new file mode 100644 index 000000000..694d77ff0 --- /dev/null +++ b/test/test_mixed_mpf_float.cpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. 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_ + +#ifdef _MSC_VER +# define _SCL_SECURE_NO_WARNINGS +#endif + +#include +#include "test_mixed.hpp" + +int main() +{ + try{ + typedef boost::multiprecision::number, boost::multiprecision::et_on> big_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_on> small_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_off> big_type2; + typedef boost::multiprecision::number, boost::multiprecision::et_off> small_type2; + + test(); + test(); + test(); + test(); + } + catch(const std::exception& e) + { + std::cout << "Failed with unexpected exception: " << e.what() << std::endl; + return 1; + } + return boost::report_errors(); +} + diff --git a/test/test_mixed_mpfr_float.cpp b/test/test_mixed_mpfr_float.cpp new file mode 100644 index 000000000..4cdc40665 --- /dev/null +++ b/test/test_mixed_mpfr_float.cpp @@ -0,0 +1,33 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. 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_ + +#ifdef _MSC_VER +# define _SCL_SECURE_NO_WARNINGS +#endif + +#include +#include "test_mixed.hpp" + +int main() +{ + try{ + typedef boost::multiprecision::number, boost::multiprecision::et_on> big_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_on> small_type1; + typedef boost::multiprecision::number, boost::multiprecision::et_off> big_type2; + typedef boost::multiprecision::number, boost::multiprecision::et_off> small_type2; + + test(); + test(); + test(); + test(); + } + catch(const std::exception& e) + { + std::cout << "Failed with unexpected exception: " << e.what() << std::endl; + return 1; + } + return boost::report_errors(); +} +