example08.run-fail.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // (C) Copyright Gennadiy Rozental 2011-2015.
  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_ALTERNATIVE_INIT_API
  8. #include <boost/test/included/unit_test.hpp>
  9. #include <boost/test/tools/floating_point_comparison.hpp>
  10. #include <boost/test/parameterized_test.hpp>
  11. #include <boost/bind.hpp>
  12. using namespace boost::unit_test;
  13. namespace tt=boost::test_tools;
  14. using namespace boost;
  15. class test_class {
  16. public:
  17. void test_method( double d )
  18. {
  19. BOOST_TEST( d * 100 == (double)(int)(d*100), tt::tolerance(0.0001) );
  20. }
  21. } tester;
  22. bool init_unit_test()
  23. {
  24. double params[] = { 1., 1.1, 1.01, 1.001, 1.0001 };
  25. boost::function<void (double)> test_method = bind( &test_class::test_method, &tester, _1);
  26. framework::master_test_suite().
  27. add( BOOST_PARAM_TEST_CASE( test_method, params, params+5 ) );
  28. return true;
  29. }
  30. //]