Index: boost/test/tools/floating_point_comparison.hpp =================================================================== --- boost/test/tools/floating_point_comparison.hpp (revision 83429) +++ boost/test/tools/floating_point_comparison.hpp (working copy) @@ -18,12 +18,13 @@ // Boost.Test #include #include - +#include // Boost #include // for std::numeric_limits #include // for numeric::conversion_traits #include #include +#include // STL #include @@ -173,7 +174,15 @@ // if one type is floating and the second integral we use floating type and // value of integral type is promoted to the floating. The same for float and double // But we don't want to compare two values of integral types using this tool. - typedef typename numeric::conversion_traits::supertype type; + typedef typename mpl::if_c< + is_convertible::value && !is_convertible::value, + FPT2, + typename mpl::if_c< + !is_convertible::value && is_convertible::value, + FPT1, + typename numeric::conversion_traits::supertype + >::type + >::type type; BOOST_STATIC_ASSERT( !is_integral::value ); }; @@ -204,7 +213,7 @@ // Action method bool operator()( FPT left, FPT right ) const { - FPT diff = fpc_detail::fpt_abs( left - right ); + FPT diff = fpc_detail::fpt_abs( static_cast(left - right) ); FPT fraction_of_right = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( right ) ); FPT fraction_of_left = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( left ) ); Index: boost/test/tools/old/impl.hpp =================================================================== --- boost/test/tools/old/impl.hpp (revision 83429) +++ boost/test/tools/old/impl.hpp (working copy) @@ -323,6 +323,13 @@ { return fpc::is_small( fpv, tolerance ); } + template + bool + operator()( FPT1 fpv, FPT2 tolerance ) const + { + typedef typename fpc::comp_supertype::type common_type; + return fpc::is_small( static_cast(fpv), static_cast(tolerance)); + } }; //____________________________________________________________________________// Index: libs/test/test/Jamfile.v2 =================================================================== --- libs/test/test/Jamfile.v2 (revision 83429) +++ libs/test/test/Jamfile.v2 (working copy) @@ -91,6 +91,7 @@ [ test-btl-lib run : test_datasets_cxx11 : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : : gcc:-std=gnu++0x ] # [ test-btl-lib run : config_file_iterator_test : boost_unit_test_framework/static ] # [ test-btl-lib run : config_file_test : boost_unit_test_framework/static ] + [ test-btl-lib run : test_expression_template_fpt : boost_unit_test_framework ] ; test-suite "multithreaded_test" @@ -103,3 +104,4 @@ # Only run tests when explicitly requested # explicit test basics_test prg_exec_monitor_test unit_test_framework_test ; + Index: libs/test/test/test_expression_template_fpt.cpp =================================================================== --- libs/test/test/test_expression_template_fpt.cpp (revision 0) +++ libs/test/test/test_expression_template_fpt.cpp (working copy) @@ -0,0 +1,36 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2013 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) + + +#include +#define BOOST_TEST_MODULE multiprecision +#include + +BOOST_AUTO_TEST_CASE(multiprecision) +{ + using namespace boost::multiprecision; + + cpp_dec_float_50 a(0), b(0), c(1); + cpp_dec_float_50 eps = std::numeric_limits::epsilon(); + + BOOST_CHECK_EQUAL(a, b); + BOOST_CHECK_NE(a, c); + BOOST_CHECK_LE(a, b); + BOOST_CHECK_GE(a, b); + BOOST_CHECK_GT(c, a); + BOOST_CHECK_LT(a, c); + + BOOST_CHECK_SMALL(a, eps); + BOOST_CHECK_SMALL(eps/2, eps); + + b = c + 10 * eps; + + BOOST_CHECK_CLOSE_FRACTION(b, c, eps * 20); + BOOST_CHECK_CLOSE(b, c, eps * 20 * 100); + + BOOST_CHECK_CLOSE_FRACTION(1 * b, c, eps * 20); + BOOST_CHECK_CLOSE(1 * b, c, eps * 20 * 100); +} +