]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/doc/examples/example08.run-fail.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / test / doc / examples / example08.run-fail.cpp
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/floating_point_comparison.hpp>
12 #include <boost/test/parameterized_test.hpp>
13 #include <boost/bind.hpp>
14 using namespace boost::unit_test;
15 namespace tt=boost::test_tools;
16 using namespace boost;
17
18 class test_class {
19 public:
20 void test_method( double d )
21 {
22 BOOST_TEST( d * 100 == (double)(int)(d*100), tt::tolerance(0.0001) );
23 }
24 } tester;
25
26 bool init_unit_test()
27 {
28 double params[] = { 1., 1.1, 1.01, 1.001, 1.0001 };
29
30 boost::function<void (double)> test_method = bind( &test_class::test_method, &tester, _1);
31
32 framework::master_test_suite().
33 add( BOOST_PARAM_TEST_CASE( test_method, params, params+5 ) );
34
35 return true;
36 }
37 //]