tolerance_05.run-fail.cpp 882 B

123456789101112131415161718192021222324
  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_05
  8. #include <boost/test/included/unit_test.hpp>
  9. #include <boost/optional.hpp>
  10. #include <boost/optional/optional_io.hpp>
  11. BOOST_AUTO_TEST_CASE(test, * boost::unit_test::tolerance(0.02))
  12. {
  13. double d1 = 1.00, d2 = 0.99;
  14. boost::optional<double> o1 = 1.00, o2 = 0.99;
  15. BOOST_TEST(d1 == d2); // with tolerance (double vs. double)
  16. BOOST_TEST(o1 == o2); // without tolerance (optional vs. optional)
  17. BOOST_TEST(o1 == d2); // without tolerance (optional vs. double)
  18. BOOST_TEST(*o1 == *o2); // with tolerance (double vs. double)
  19. }
  20. //]