[test] interfacing with units proposal

This may be of interest to the Boost.Test maintainers... Matthias
From: Steven Watanabe <steven@providere-consulting.com> Date: March 28, 2007 11:55:39 AM MDT To: Matthias Schabel <boost@schabel-family.org> Cc: "K. R. Walker" <krwalker@stellarscience.com> Subject: Re: [boost][units] interfacing with boost::ublas
AMDG
Matthias Schabel wrote:
This ought to work (untested) :
BOOST_CHECK_CLOSE(a,b,0.1*SI::meters); It doesn't. The comparison is fine as is.
replace floating_point_comparison.hpp line 71 ff. with
template<typename FPT, typename PersentType = FPT > class close_at_tolerance { public: // Public typedefs typedef bool result_type;
// Constructor explicit close_at_tolerance( PersentType percentage_tolerance, floating_point_comparison_type fpc_type = FPC_STRONG ) : p_fraction_tolerance( static_cast<FPT>(0.01) *percentage_tolerance ), p_strong_or_weak( fpc_type == FPC_STRONG ) {}
bool operator()( FPT left, FPT right ) const { FPT diff = tt_detail::fpt_abs( left - right ); return impl(tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) ), tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs ( left ) )); }
template<class F> bool impl(F d1,F d2) const { return p_strong_or_weak ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get()) : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()); }
// Public properties readonly_property<FPT> p_fraction_tolerance; readonly_property<bool> p_strong_or_weak; };
In Christ, Steven Watanabe
participants (1)
-
Matthias Schabel