1 // (C) Copyright Gennadiy Rozental 2001.
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)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision: 74248 $
12 // Description : FPC tools tolerance holder
13 // ***************************************************************************
15 #ifndef BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
16 #define BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
19 #include <boost/test/tree/decorator.hpp>
20 #include <boost/test/tools/floating_point_comparison.hpp>
22 #include <boost/test/detail/suppress_warnings.hpp>
24 //____________________________________________________________________________//
27 namespace test_tools {
29 namespace fpc = math::fpc;
31 // ************************************************************************** //
32 // ************** floating point comparison tolerance ************** //
33 // ************************************************************************** //
35 template<typename FPT>
39 static FPT s_value = 0;
43 //____________________________________________________________________________//
45 template<typename FPT>
46 struct local_fpc_tolerance {
47 local_fpc_tolerance( FPT fraction_tolerance ) : m_old_tolerance( fpc_tolerance<FPT>() )
49 fpc_tolerance<FPT>() = fraction_tolerance;
52 ~local_fpc_tolerance()
54 if( m_old_tolerance != (FPT)-1 )
55 fpc_tolerance<FPT>() = m_old_tolerance;
63 //____________________________________________________________________________//
65 } // namespace test_tools
67 // ************************************************************************** //
68 // ************** decorator::tolerance ************** //
69 // ************************************************************************** //
74 template<typename FPT>
78 return fixture_t( test_unit_fixture_ptr(
79 new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( v ) ) );
82 //____________________________________________________________________________//
84 template<typename FPT>
86 tolerance( test_tools::fpc::percent_tolerance_t<FPT> v )
88 return fixture_t( test_unit_fixture_ptr(
89 new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( boost::math::fpc::fpc_detail::fraction_tolerance<FPT>( v ) ) ) );
92 //____________________________________________________________________________//
94 } // namespace decorator
96 using decorator::tolerance;
98 } // namespace unit_test
101 #include <boost/test/detail/enable_warnings.hpp>
103 #endif // BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER