Ticket #8272: test_multiprecision.patch
File test_multiprecision.patch, 4.8 KB (added by , 10 years ago) |
---|
-
boost/test/tools/floating_point_comparison.hpp
18 18 // Boost.Test 19 19 #include <boost/test/detail/global_typedef.hpp> 20 20 #include <boost/test/tools/assertion_result.hpp> 21 21 #include <boost/type_traits/is_convertible.hpp> 22 22 // Boost 23 23 #include <boost/limits.hpp> // for std::numeric_limits 24 24 #include <boost/numeric/conversion/conversion_traits.hpp> // for numeric::conversion_traits 25 25 #include <boost/static_assert.hpp> 26 26 #include <boost/assert.hpp> 27 #include <boost/mpl/if.hpp> 27 28 28 29 // STL 29 30 #include <iosfwd> … … 173 174 // if one type is floating and the second integral we use floating type and 174 175 // value of integral type is promoted to the floating. The same for float and double 175 176 // But we don't want to compare two values of integral types using this tool. 176 typedef typename numeric::conversion_traits<FPT1,FPT2>::supertype type; 177 typedef typename mpl::if_c< 178 is_convertible<FPT1, FPT2>::value && !is_convertible<FPT2, FPT1>::value, 179 FPT2, 180 typename mpl::if_c< 181 !is_convertible<FPT1, FPT2>::value && is_convertible<FPT2, FPT1>::value, 182 FPT1, 183 typename numeric::conversion_traits<FPT1,FPT2>::supertype 184 >::type 185 >::type type; 177 186 BOOST_STATIC_ASSERT( !is_integral<type>::value ); 178 187 }; 179 188 … … 204 213 // Action method 205 214 bool operator()( FPT left, FPT right ) const 206 215 { 207 FPT diff = fpc_detail::fpt_abs( left - right);216 FPT diff = fpc_detail::fpt_abs( static_cast<FPT>(left - right) ); 208 217 FPT fraction_of_right = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( right ) ); 209 218 FPT fraction_of_left = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( left ) ); 210 219 -
boost/test/tools/old/impl.hpp
323 323 { 324 324 return fpc::is_small( fpv, tolerance ); 325 325 } 326 template<typename FPT1, class FPT2> 327 bool 328 operator()( FPT1 fpv, FPT2 tolerance ) const 329 { 330 typedef typename fpc::comp_supertype<FPT1, FPT2>::type common_type; 331 return fpc::is_small( static_cast<common_type>(fpv), static_cast<common_type>(tolerance)); 332 } 326 333 }; 327 334 328 335 //____________________________________________________________________________// -
libs/test/test/Jamfile.v2
91 91 [ test-btl-lib run : test_datasets_cxx11 : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : : <toolset>gcc:<cxxflags>-std=gnu++0x ] 92 92 # [ test-btl-lib run : config_file_iterator_test : boost_unit_test_framework/<link>static ] 93 93 # [ test-btl-lib run : config_file_test : boost_unit_test_framework/<link>static ] 94 [ test-btl-lib run : test_expression_template_fpt : boost_unit_test_framework ] 94 95 ; 95 96 96 97 test-suite "multithreaded_test" … … 103 104 104 105 # Only run tests when explicitly requested 105 106 # explicit test basics_test prg_exec_monitor_test unit_test_framework_test ; 107 -
libs/test/test/test_expression_template_fpt.cpp
1 /////////////////////////////////////////////////////////////////////////////// 2 // Copyright 2013 John Maddock. Distributed under the Boost 3 // Software License, Version 1.0. (See accompanying file 4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 7 #include <boost/multiprecision/cpp_dec_float.hpp> 8 #define BOOST_TEST_MODULE multiprecision 9 #include <boost/test/unit_test.hpp> 10 11 BOOST_AUTO_TEST_CASE(multiprecision) 12 { 13 using namespace boost::multiprecision; 14 15 cpp_dec_float_50 a(0), b(0), c(1); 16 cpp_dec_float_50 eps = std::numeric_limits<cpp_dec_float_50>::epsilon(); 17 18 BOOST_CHECK_EQUAL(a, b); 19 BOOST_CHECK_NE(a, c); 20 BOOST_CHECK_LE(a, b); 21 BOOST_CHECK_GE(a, b); 22 BOOST_CHECK_GT(c, a); 23 BOOST_CHECK_LT(a, c); 24 25 BOOST_CHECK_SMALL(a, eps); 26 BOOST_CHECK_SMALL(eps/2, eps); 27 28 b = c + 10 * eps; 29 30 BOOST_CHECK_CLOSE_FRACTION(b, c, eps * 20); 31 BOOST_CHECK_CLOSE(b, c, eps * 20 * 100); 32 33 BOOST_CHECK_CLOSE_FRACTION(1 * b, c, eps * 20); 34 BOOST_CHECK_CLOSE(1 * b, c, eps * 20 * 100); 35 } 36