• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
6 //  See http://www.boost.org/libs/test for the library home page.
7 
8 //[example_code
9 #define BOOST_TEST_ALTERNATIVE_INIT_API
10 #include <boost/test/included/unit_test.hpp>
11 #include <boost/test/tools/floating_point_comparison.hpp>
12 #include <boost/test/parameterized_test.hpp>
13 #include <boost/bind/bind.hpp>
14 using namespace boost::unit_test;
15 namespace tt=boost::test_tools;
16 
17 
18 class test_class {
19 public:
test_method(double d)20   void test_method( double d )
21   {
22     BOOST_TEST( d * 100 == (double)(int)(d*100), tt::tolerance(0.0001) );
23   }
24 } tester;
25 
init_unit_test()26 bool init_unit_test()
27 {
28   using boost::bind;
29   using boost::placeholders::_1;
30   double params[] = { 1., 1.1, 1.01, 1.001, 1.0001 };
31 
32   boost::function<void (double)> test_method = bind( &test_class::test_method, &tester, _1);
33 
34   framework::master_test_suite().
35     add( BOOST_PARAM_TEST_CASE( test_method, params, params+5 ) );
36 
37   return true;
38 }
39 //]
40