tolerance_06.run-fail.cpp 855 B

1234567891011121314151617181920212223
  1. // Copyright (c) 2015 Boost.Test team
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //[example_code
  7. #define BOOST_TEST_MODULE tolerance_06
  8. #include <boost/test/included/unit_test.hpp>
  9. namespace utf = boost::unit_test;
  10. namespace tt = boost::test_tools;
  11. BOOST_AUTO_TEST_CASE(test1, * utf::tolerance(0.1415 / 3)) // == 0.047166667
  12. {
  13. double x = 3.141592404915836;
  14. // x is 'double' which is tolerance based, 3 is 'int' which is arithmetic:
  15. // tolerance based comparison will be used.
  16. // Type of tolerance for this comparison will be boost::common_type<double, int>::type == double
  17. // Value for this tolerance type is set by the decorator.
  18. BOOST_TEST(x == 3);
  19. }
  20. //]