mirror of
https://github.com/boostorg/test.git
synced 2026-01-24 18:32:30 +00:00
introduce fpc::tolerance_based to be used instead of is_floating_point. This should allow us to extend tolerance based comparisons t omore types
This commit is contained in:
@@ -47,7 +47,7 @@ rule test-btl-lib-c11 ( test-rule : test-name : lib-name ? : pattern_file * : so
|
||||
# So deactivate those warnings again
|
||||
<toolset>gcc:<cxxflags>-pedantic
|
||||
<toolset>gcc:<cxxflags>-Wno-long-long
|
||||
#<toolset>gcc:<cxxflags>-std=gnu++0x
|
||||
<toolset>gcc:<cxxflags>-std=c++11
|
||||
<toolset>gcc-4.5:<cxxflags>-std=gnu++0x
|
||||
<toolset>gcc-4.7:<cxxflags>-std=gnu++11
|
||||
<toolset>borland:<cxxflags>-w-8080
|
||||
@@ -79,7 +79,7 @@ rule test-btl-lib-mt ( test-rule : test-name : lib-name ? : pattern_file * : sou
|
||||
<toolset>borland:<cxxflags>-w-8080
|
||||
<toolset>msvc-6.5:<link>static
|
||||
<toolset>msvc-8.0:<define>_SCL_SECURE_NO_DEPRECATE
|
||||
#<toolset>gcc:<cxxflags>-std=gnu++0x
|
||||
<toolset>gcc:<cxxflags>-std=c++11
|
||||
<toolset>gcc-4.5:<cxxflags>-std=gnu++0x
|
||||
<toolset>gcc-4.7:<cxxflags>-std=gnu++11
|
||||
<toolset>clang:<cxxflags>-Wno-c99-extensions
|
||||
@@ -131,7 +131,7 @@ test-suite "unit_test_framework_test"
|
||||
[ test-btl-lib run : test_assertion_construction : boost_unit_test_framework/<link>static ]
|
||||
[ test-btl-lib run : test_datasets : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ]
|
||||
[ test-btl-lib-c11 run : test_datasets_cxx11 : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ]
|
||||
|
||||
|
||||
# [ test-btl-lib run : config_file_iterator_test : boost_unit_test_framework/<link>static ]
|
||||
# [ test-btl-lib run : config_file_test : boost_unit_test_framework/<link>static ]
|
||||
|
||||
@@ -139,7 +139,7 @@ test-suite "unit_test_framework_test"
|
||||
[ test-btl-lib run : test_dont_print_log_value : boost_unit_test_framework ]
|
||||
|
||||
# test for multiprecision / trac 11054
|
||||
[ test-btl-lib run : test_fp_multiprecision_close_fraction : boost_unit_test_framework ]
|
||||
[ test-btl-lib-c11 run : test_fp_multiprecision_close_fraction : boost_unit_test_framework ]
|
||||
;
|
||||
|
||||
test-suite "multithreaded_test"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#define BOOST_LIB_DIAGNOSTIC "on"// Show library file details.
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp> // Extra test tool for FP comparison.
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
@@ -46,7 +45,7 @@ if desired, as shown below.
|
||||
*/
|
||||
|
||||
using namespace boost::multiprecision;
|
||||
|
||||
namespace tt = boost::test_tools;
|
||||
|
||||
/*`Now `cpp_dec_float_50_noet` or `cpp_dec_float_50_et`
|
||||
can be used as a direct replacement for built-in types like `double` etc.
|
||||
@@ -67,10 +66,9 @@ BOOST_AUTO_TEST_CASE(cpp_float_test_check_close_noet)
|
||||
|
||||
std::cout <<"a = " << a << ",\nb = " << b << ",\neps = " << eps << std::endl;
|
||||
|
||||
BOOST_CHECK_CLOSE(a, b, eps * 100); // Expected to pass (because tolerance is as percent).
|
||||
BOOST_CHECK_CLOSE_FRACTION(a, b, eps); // Expected to pass (because tolerance is as fraction).
|
||||
BOOST_TEST( a == b, tt::tolerance( tt::fpc::percent_tolerance( eps * 100 ) ) );
|
||||
BOOST_TEST( a == b, tt::tolerance( eps ) );
|
||||
|
||||
|
||||
//] [/expression_template_1]git
|
||||
|
||||
} // BOOST_AUTO_TEST_CASE(cpp_float_test_check_close)
|
||||
@@ -90,8 +88,8 @@ BOOST_AUTO_TEST_CASE(cpp_float_test_check_close_et)
|
||||
|
||||
std::cout << "a = " << a << ",\nb = " << b << ",\neps = " << eps << std::endl;
|
||||
|
||||
BOOST_CHECK_CLOSE(a, b, eps * 100); // Expected to pass (because tolerance is as percent).
|
||||
BOOST_CHECK_CLOSE_FRACTION(a, b, eps); // Expected to pass (because tolerance is as fraction).
|
||||
BOOST_TEST( a == b, tt::tolerance( tt::fpc::percent_tolerance( (cpp_dec_float_50_et)(eps * 100) ) ) );
|
||||
BOOST_TEST( a == b, tt::tolerance( eps ) );
|
||||
|
||||
/*`Using `cpp_dec_float_50` with the default expression template use switched on,
|
||||
the compiler error message for `BOOST_CHECK_CLOSE_FRACTION(a, b, eps); would be:
|
||||
@@ -108,13 +106,12 @@ Output:
|
||||
|
||||
Description: Autorun "J:\Cpp\big_number\Debug\test_cpp_float_close_fraction.exe"
|
||||
Running 1 test case...
|
||||
|
||||
|
||||
a = 1.0000000000000000000000000000000000000000000000000,
|
||||
b = 1.0000000000000000000000000000000000000000000000001,
|
||||
eps = 1.0000000000000000000000000000000000000000000000000e-49
|
||||
|
||||
*** No errors detected
|
||||
|
||||
*** No errors detected
|
||||
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user