File indexing completed on 2025-01-18 09:52:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
0016 #define BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
0017
0018
0019 #include <boost/test/tree/decorator.hpp>
0020 #include <boost/test/tools/floating_point_comparison.hpp>
0021
0022 #include <boost/test/detail/suppress_warnings.hpp>
0023
0024
0025
0026 namespace boost {
0027 namespace test_tools {
0028
0029 namespace fpc = math::fpc;
0030
0031
0032
0033
0034
0035 template<typename FPT>
0036 inline FPT&
0037 fpc_tolerance()
0038 {
0039 static FPT s_value = 0;
0040 return s_value;
0041 }
0042
0043
0044
0045 template<typename FPT>
0046 struct local_fpc_tolerance {
0047 local_fpc_tolerance( FPT fraction_tolerance ) : m_old_tolerance( fpc_tolerance<FPT>() )
0048 {
0049 fpc_tolerance<FPT>() = fraction_tolerance;
0050 }
0051
0052 ~local_fpc_tolerance()
0053 {
0054 if( m_old_tolerance != (FPT)-1 )
0055 fpc_tolerance<FPT>() = m_old_tolerance;
0056 }
0057
0058 private:
0059
0060 FPT m_old_tolerance;
0061 };
0062
0063
0064
0065 }
0066
0067
0068
0069
0070
0071 namespace unit_test {
0072 namespace decorator {
0073
0074 template<typename FPT>
0075 inline fixture_t
0076 tolerance( FPT v )
0077 {
0078 return fixture_t( test_unit_fixture_ptr(
0079 new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( v ) ) );
0080 }
0081
0082
0083
0084 template<typename FPT>
0085 inline fixture_t
0086 tolerance( test_tools::fpc::percent_tolerance_t<FPT> v )
0087 {
0088 return fixture_t( test_unit_fixture_ptr(
0089 new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( boost::math::fpc::fpc_detail::fraction_tolerance<FPT>( v ) ) ) );
0090 }
0091
0092
0093
0094 }
0095
0096 using decorator::tolerance;
0097
0098 }
0099 }
0100
0101 #include <boost/test/detail/enable_warnings.hpp>
0102
0103 #endif