updated boost on windows
This commit is contained in:
@@ -277,7 +277,7 @@ public:
|
||||
}
|
||||
void report( std::ostream& ostr ) const
|
||||
{
|
||||
ostr << tt_detail::print_helper( m_value );
|
||||
ostr << tt_detail::print_helper( value() );
|
||||
}
|
||||
|
||||
// Mutating operators
|
||||
@@ -309,8 +309,11 @@ public:
|
||||
|
||||
private:
|
||||
template<typename U>
|
||||
static void format_message( wrap_stringstream& ostr, U const& v ) { ostr << "[(bool)" << v << " is false]"; }
|
||||
static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {}
|
||||
static void format_message( wrap_stringstream& ostr, U const& v )
|
||||
{
|
||||
ostr << "['" << tt_detail::print_helper(v) << "' evaluates to false]";
|
||||
}
|
||||
static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {}
|
||||
static void format_message( wrap_stringstream& /*ostr*/, assertion_result const& /*v*/ ) {}
|
||||
|
||||
// Data members
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
// Boost
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
|
||||
@@ -38,6 +39,15 @@ namespace assertion {
|
||||
template<typename T>
|
||||
struct specialized_compare : public mpl::false_ {};
|
||||
|
||||
template <typename T>
|
||||
struct is_c_array : public mpl::false_ {};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct is_c_array<T [N]> : public mpl::true_ {};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct is_c_array<T (&)[N]> : public mpl::true_ {};
|
||||
|
||||
#define BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(Col) \
|
||||
namespace boost { namespace test_tools { namespace assertion { \
|
||||
template<> \
|
||||
@@ -55,17 +65,21 @@ template <typename OP, bool can_be_equal, bool prefer_shorter,
|
||||
typename Lhs, typename Rhs>
|
||||
inline
|
||||
typename boost::enable_if_c<
|
||||
unit_test::is_forward_iterable<Lhs>::value && unit_test::is_forward_iterable<Rhs>::value,
|
||||
unit_test::is_forward_iterable<Lhs>::value && !unit_test::is_cstring<Lhs>::value
|
||||
&& unit_test::is_forward_iterable<Rhs>::value && !unit_test::is_cstring<Rhs>::value,
|
||||
assertion_result>::type
|
||||
lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
assertion_result ar( true );
|
||||
|
||||
typename Lhs::const_iterator first1 = lhs.begin();
|
||||
typename Rhs::const_iterator first2 = rhs.begin();
|
||||
typename Lhs::const_iterator last1 = lhs.end();
|
||||
typename Rhs::const_iterator last2 = rhs.end();
|
||||
std::size_t pos = 0;
|
||||
typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator;
|
||||
typedef unit_test::bt_iterator_traits<Rhs> t_Rhs_iterator;
|
||||
|
||||
typename t_Lhs_iterator::const_iterator first1 = t_Lhs_iterator::begin(lhs);
|
||||
typename t_Rhs_iterator::const_iterator first2 = t_Rhs_iterator::begin(rhs);
|
||||
typename t_Lhs_iterator::const_iterator last1 = t_Lhs_iterator::end(lhs);
|
||||
typename t_Rhs_iterator::const_iterator last2 = t_Rhs_iterator::end(rhs);
|
||||
std::size_t pos = 0;
|
||||
|
||||
for( ; (first1 != last1) && (first2 != last2); ++first1, ++first2, ++pos ) {
|
||||
assertion_result const& element_ar = OP::eval(*first1, *first2);
|
||||
@@ -113,8 +127,7 @@ template <typename OP, bool can_be_equal, bool prefer_shorter,
|
||||
typename Lhs, typename Rhs>
|
||||
inline
|
||||
typename boost::enable_if_c<
|
||||
(!unit_test::is_forward_iterable<Lhs>::value && unit_test::is_cstring<Lhs>::value) ||
|
||||
(!unit_test::is_forward_iterable<Rhs>::value && unit_test::is_cstring<Rhs>::value),
|
||||
(unit_test::is_cstring<Lhs>::value || unit_test::is_cstring<Rhs>::value),
|
||||
assertion_result>::type
|
||||
lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
@@ -122,8 +135,8 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type;
|
||||
|
||||
return lexicographic_compare<OP, can_be_equal, prefer_shorter>(
|
||||
boost::unit_test::basic_cstring<lhs_char_type>(lhs),
|
||||
boost::unit_test::basic_cstring<rhs_char_type>(rhs));
|
||||
lhs_char_type(lhs),
|
||||
rhs_char_type(rhs));
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -135,23 +148,27 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
template <typename OP, typename Lhs, typename Rhs>
|
||||
inline
|
||||
typename boost::enable_if_c<
|
||||
unit_test::is_forward_iterable<Lhs>::value && unit_test::is_forward_iterable<Rhs>::value,
|
||||
unit_test::is_forward_iterable<Lhs>::value && !unit_test::is_cstring<Lhs>::value
|
||||
&& unit_test::is_forward_iterable<Rhs>::value && !unit_test::is_cstring<Rhs>::value,
|
||||
assertion_result>::type
|
||||
element_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator;
|
||||
typedef unit_test::bt_iterator_traits<Rhs> t_Rhs_iterator;
|
||||
|
||||
assertion_result ar( true );
|
||||
|
||||
if( lhs.size() != rhs.size() ) {
|
||||
if( t_Lhs_iterator::size(lhs) != t_Rhs_iterator::size(rhs) ) {
|
||||
ar = false;
|
||||
ar.message() << "\nCollections size mismatch: " << lhs.size() << " != " << rhs.size();
|
||||
ar.message() << "\nCollections size mismatch: " << t_Lhs_iterator::size(lhs) << " != " << t_Rhs_iterator::size(rhs);
|
||||
return ar;
|
||||
}
|
||||
|
||||
typename Lhs::const_iterator left = lhs.begin();
|
||||
typename Rhs::const_iterator right = rhs.begin();
|
||||
std::size_t pos = 0;
|
||||
typename t_Lhs_iterator::const_iterator left = t_Lhs_iterator::begin(lhs);
|
||||
typename t_Rhs_iterator::const_iterator right = t_Rhs_iterator::begin(rhs);
|
||||
std::size_t pos = 0;
|
||||
|
||||
for( ; pos < lhs.size(); ++left, ++right, ++pos ) {
|
||||
for( ; pos < t_Lhs_iterator::size(lhs); ++left, ++right, ++pos ) {
|
||||
assertion_result const element_ar = OP::eval( *left, *right );
|
||||
if( element_ar )
|
||||
continue;
|
||||
@@ -171,16 +188,15 @@ element_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
template <typename OP, typename Lhs, typename Rhs>
|
||||
inline
|
||||
typename boost::enable_if_c<
|
||||
(!unit_test::is_forward_iterable<Lhs>::value && unit_test::is_cstring<Lhs>::value) ||
|
||||
(!unit_test::is_forward_iterable<Rhs>::value && unit_test::is_cstring<Rhs>::value),
|
||||
(unit_test::is_cstring<Lhs>::value || unit_test::is_cstring<Rhs>::value),
|
||||
assertion_result>::type
|
||||
element_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type;
|
||||
typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type;
|
||||
|
||||
return element_compare<OP>(boost::unit_test::basic_cstring<lhs_char_type>(lhs),
|
||||
boost::unit_test::basic_cstring<rhs_char_type>(rhs));
|
||||
return element_compare<OP>(lhs_char_type(lhs),
|
||||
rhs_char_type(rhs));
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -193,14 +209,17 @@ template <typename OP, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
non_equality_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator;
|
||||
typedef unit_test::bt_iterator_traits<Rhs> t_Rhs_iterator;
|
||||
|
||||
assertion_result ar( true );
|
||||
|
||||
if( lhs.size() != rhs.size() )
|
||||
if( t_Lhs_iterator::size(lhs) != t_Rhs_iterator::size(rhs) )
|
||||
return ar;
|
||||
|
||||
typename Lhs::const_iterator left = lhs.begin();
|
||||
typename Rhs::const_iterator right = rhs.begin();
|
||||
typename Lhs::const_iterator end = lhs.end();
|
||||
typename t_Lhs_iterator::const_iterator left = t_Lhs_iterator::begin(lhs);
|
||||
typename t_Rhs_iterator::const_iterator right = t_Rhs_iterator::begin(rhs);
|
||||
typename t_Lhs_iterator::const_iterator end = t_Lhs_iterator::end(lhs);
|
||||
|
||||
for( ; left != end; ++left, ++right ) {
|
||||
if( OP::eval( *left, *right ) )
|
||||
@@ -367,22 +386,34 @@ compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GE<L, R> >*
|
||||
#define DEFINE_COLLECTION_COMPARISON( oper, name, rev ) \
|
||||
template<typename Lhs,typename Rhs> \
|
||||
struct name<Lhs,Rhs,typename boost::enable_if_c< \
|
||||
unit_test::is_forward_iterable<Lhs>::value \
|
||||
&& !unit_test::is_cstring<Lhs>::value \
|
||||
&& unit_test::is_forward_iterable<Rhs>::value \
|
||||
&& !unit_test::is_cstring<Rhs>::value>::type> { \
|
||||
unit_test::is_forward_iterable<Lhs>::value \
|
||||
&& !unit_test::is_cstring_comparable<Lhs>::value \
|
||||
&& unit_test::is_forward_iterable<Rhs>::value \
|
||||
&& !unit_test::is_cstring_comparable<Rhs>::value>::type> { \
|
||||
public: \
|
||||
typedef assertion_result result_type; \
|
||||
typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator_helper; \
|
||||
typedef unit_test::bt_iterator_traits<Rhs> t_Rhs_iterator_helper; \
|
||||
\
|
||||
typedef name<Lhs, Rhs> OP; \
|
||||
typedef typename \
|
||||
mpl::if_c<is_same<typename decay<Lhs>::type, \
|
||||
typename decay<Rhs>::type>::value, \
|
||||
typename cctraits<OP>::is_specialized, \
|
||||
mpl::false_>::type is_specialized; \
|
||||
\
|
||||
typedef name<typename Lhs::value_type, \
|
||||
typename Rhs::value_type> elem_op; \
|
||||
typedef typename \
|
||||
mpl::if_c< \
|
||||
mpl::or_< \
|
||||
typename is_c_array<Lhs>::type, \
|
||||
typename is_c_array<Rhs>::type \
|
||||
>::value, \
|
||||
mpl::true_, \
|
||||
typename \
|
||||
mpl::if_c<is_same<typename decay<Lhs>::type, \
|
||||
typename decay<Rhs>::type>::value, \
|
||||
typename cctraits<OP>::is_specialized, \
|
||||
mpl::false_>::type \
|
||||
>::type is_specialized; \
|
||||
\
|
||||
typedef name<typename t_Lhs_iterator_helper::value_type, \
|
||||
typename t_Rhs_iterator_helper::value_type \
|
||||
> elem_op; \
|
||||
\
|
||||
static assertion_result \
|
||||
eval( Lhs const& lhs, Rhs const& rhs) \
|
||||
|
||||
@@ -17,6 +17,20 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/lazy_ostream.hpp>
|
||||
#include <boost/test/detail/pp_variadic.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/variadic/size.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/seq/for_each_i.hpp>
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
#include <boost/preprocessor/seq/enum.hpp>
|
||||
#include <boost/preprocessor/control/iif.hpp>
|
||||
#include <boost/preprocessor/comparison/equal.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
@@ -47,13 +61,30 @@ private:
|
||||
::boost::unit_test::framework::add_context( BOOST_TEST_LAZY_MSG( context_descr ) , false ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST_INFO_SCOPE( context_descr ) \
|
||||
::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) = \
|
||||
::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_CONTEXT( context_descr ) \
|
||||
if( ::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) = \
|
||||
::boost::test_tools::tt_detail::context_frame( BOOST_TEST_LAZY_MSG( context_descr ) ) ) \
|
||||
|
||||
#define BOOST_CONTEXT_PARAM(r, ctx, i, context_descr) \
|
||||
if( ::boost::test_tools::tt_detail::context_frame BOOST_PP_CAT(ctx, i) = \
|
||||
::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_CONTEXT_PARAMS( params ) \
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONTEXT_PARAM, \
|
||||
BOOST_JOIN( context_frame_, __LINE__ ), \
|
||||
params) \
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST_CONTEXT( ... ) \
|
||||
BOOST_CONTEXT_PARAMS( BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) ) \
|
||||
/**/
|
||||
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace op {
|
||||
#define DEFINE_CSTRING_COMPARISON( oper, name, rev ) \
|
||||
template<typename Lhs,typename Rhs> \
|
||||
struct name<Lhs,Rhs,typename boost::enable_if_c< \
|
||||
( unit_test::is_cstring<Lhs>::value \
|
||||
&& unit_test::is_cstring<Rhs>::value) \
|
||||
( unit_test::is_cstring_comparable<Lhs>::value \
|
||||
&& unit_test::is_cstring_comparable<Rhs>::value) \
|
||||
>::type > \
|
||||
{ \
|
||||
typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type; \
|
||||
@@ -46,13 +46,14 @@ struct name<Lhs,Rhs,typename boost::enable_if_c< \
|
||||
public: \
|
||||
typedef assertion_result result_type; \
|
||||
\
|
||||
typedef name<lhs_char_type, rhs_char_type> elem_op; \
|
||||
typedef name< \
|
||||
typename lhs_char_type::value_type, \
|
||||
typename rhs_char_type::value_type> elem_op; \
|
||||
\
|
||||
static bool \
|
||||
eval( Lhs const& lhs, Rhs const& rhs) \
|
||||
{ \
|
||||
return unit_test::basic_cstring<lhs_char_type>(lhs) oper \
|
||||
unit_test::basic_cstring<rhs_char_type>(rhs); \
|
||||
return lhs_char_type(lhs) oper rhs_char_type(rhs); \
|
||||
} \
|
||||
\
|
||||
template<typename PrevExprType> \
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/workaround.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/mpl/or.hpp>
|
||||
@@ -28,6 +27,8 @@
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#include <boost/type_traits/has_left_shift.hpp>
|
||||
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
@@ -166,8 +167,11 @@ struct BOOST_TEST_DECL print_log_value<wchar_t const*> {
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NULLPTR)
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<std::nullptr_t> {
|
||||
void operator()( std::ostream& ostr, std::nullptr_t t );
|
||||
struct print_log_value<std::nullptr_t> {
|
||||
// declaration and definition is here because of #12969 https://svn.boost.org/trac10/ticket/12969
|
||||
void operator()( std::ostream& ostr, std::nullptr_t /*t*/ ) {
|
||||
ostr << "nullptr";
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -197,9 +197,11 @@ fraction_tolerance( percent_tolerance_t<FPT> tolerance )
|
||||
/*!@brief Predicate for comparing floating point numbers
|
||||
*
|
||||
* This predicate is used to compare floating point numbers. In addition the comparison produces maximum
|
||||
* related differnce, which can be used to generate detailed error message
|
||||
* related difference, which can be used to generate detailed error message
|
||||
* The methods for comparing floating points are detailed in the documentation. The method is chosen
|
||||
* by the @ref boost::math::fpc::strength given at construction.
|
||||
*
|
||||
* This predicate is not suitable for comparing to 0 or to infinity.
|
||||
*/
|
||||
template<typename FPT>
|
||||
class close_at_tolerance {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
// Boost
|
||||
#include <boost/type_traits/common_type.hpp>
|
||||
#include <boost/type_traits/is_arithmetic.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
@@ -38,22 +39,19 @@ namespace op {
|
||||
|
||||
template<typename OP>
|
||||
struct fpctraits {
|
||||
static const bool cmp_direct = true;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct fpctraits<op::NE<Lhs,Rhs> > {
|
||||
static const bool cmp_direct = false;
|
||||
// indicate if we should perform the operation with a "logical OR"
|
||||
// with the "equality under tolerance".
|
||||
static const bool equality_logical_disjunction = true;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct fpctraits<op::LT<Lhs,Rhs> > {
|
||||
static const bool cmp_direct = false;
|
||||
static const bool equality_logical_disjunction = false;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct fpctraits<op::GT<Lhs,Rhs> > {
|
||||
static const bool cmp_direct = false;
|
||||
static const bool equality_logical_disjunction = false;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -62,48 +60,30 @@ struct fpctraits<op::GT<Lhs,Rhs> > {
|
||||
// ************** set of overloads to select correct fpc algo ************** //
|
||||
// ************************************************************************** //
|
||||
// we really only care about EQ vs NE. All other comparisons use direct first
|
||||
// and then need EQ. For example a < b (tolerance t) IFF a < b OR a == b (tolerance t)
|
||||
// and then need EQ. For example a <= b (tolerance t) IFF a <= b OR a == b (tolerance t)
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs, typename OP>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, OP* )
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, OP* cmp_operator)
|
||||
{
|
||||
fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_STRONG );
|
||||
|
||||
assertion_result ar( P( lhs, rhs ) );
|
||||
if( !ar )
|
||||
ar.message() << "Relative difference exceeds tolerance ["
|
||||
<< P.tested_rel_diff() << " > " << P.fraction_tolerance() << ']';
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename OP>
|
||||
inline assertion_result
|
||||
compare_fpv_near_zero( FPT const& fpv, OP* )
|
||||
{
|
||||
fpc::small_with_tolerance<FPT> P( fpc_tolerance<FPT>() );
|
||||
|
||||
assertion_result ar( P( fpv ) );
|
||||
if( !ar )
|
||||
ar.message() << "Absolute value exceeds tolerance [|" << fpv << "| > "<< fpc_tolerance<FPT>() << ']';
|
||||
|
||||
return ar;
|
||||
bool result = cmp_operator->eval_direct(lhs, rhs);
|
||||
if(fpctraits<OP>::equality_logical_disjunction) {
|
||||
return result || compare_fpv<FPT>(lhs, rhs, (op::EQ<Lhs, Rhs>*)0);
|
||||
}
|
||||
return result && compare_fpv<FPT>(lhs, rhs, (op::NE<Lhs, Rhs>*)0);
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::NE<Lhs,Rhs>* )
|
||||
compare_fpv_near_zero( FPT const& fpv, op::EQ<Lhs,Rhs>* )
|
||||
{
|
||||
fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_WEAK );
|
||||
fpc::small_with_tolerance<FPT> P( fpc_tolerance<FPT>() );
|
||||
|
||||
assertion_result ar( !P( lhs, rhs ) );
|
||||
assertion_result ar( P( fpv ) );
|
||||
if( !ar )
|
||||
ar.message() << "Relative difference is within tolerance ["
|
||||
<< P.tested_rel_diff() << " < " << fpc_tolerance<FPT>() << ']';
|
||||
ar.message() << "Absolute value exceeds tolerance [|" << fpv << "| > "<< fpc_tolerance<FPT>() << ']';
|
||||
|
||||
return ar;
|
||||
}
|
||||
@@ -126,34 +106,48 @@ compare_fpv_near_zero( FPT const& fpv, op::NE<Lhs,Rhs>* )
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::LT<Lhs,Rhs>* )
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::EQ<Lhs,Rhs>* )
|
||||
{
|
||||
return lhs >= rhs ? assertion_result( false ) : compare_fpv<FPT>( lhs, rhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
if( lhs == 0 ) {
|
||||
return compare_fpv_near_zero<FPT>( rhs, (op::EQ<Lhs,Rhs>*)0 );
|
||||
}
|
||||
else if( rhs == 0) {
|
||||
return compare_fpv_near_zero<FPT>( lhs, (op::EQ<Lhs,Rhs>*)0 );
|
||||
}
|
||||
else {
|
||||
fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_STRONG );
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv_near_zero( FPT const& fpv, op::LT<Lhs,Rhs>* )
|
||||
{
|
||||
return fpv >= 0 ? assertion_result( false ) : compare_fpv_near_zero( fpv, (op::NE<Lhs,Rhs>*)0 );
|
||||
assertion_result ar( P( lhs, rhs ) );
|
||||
if( !ar )
|
||||
ar.message() << "Relative difference exceeds tolerance ["
|
||||
<< P.tested_rel_diff() << " > " << P.fraction_tolerance() << ']';
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::GT<Lhs,Rhs>* )
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::NE<Lhs,Rhs>* )
|
||||
{
|
||||
return lhs <= rhs ? assertion_result( false ) : compare_fpv<FPT>( lhs, rhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
if( lhs == 0 ) {
|
||||
return compare_fpv_near_zero<FPT>( rhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
else if( rhs == 0 ) {
|
||||
return compare_fpv_near_zero<FPT>( lhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
else {
|
||||
fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_WEAK );
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv_near_zero( FPT const& fpv, op::GT<Lhs,Rhs>* )
|
||||
{
|
||||
return fpv <= 0 ? assertion_result( false ) : compare_fpv_near_zero( fpv, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
assertion_result ar( !P( lhs, rhs ) );
|
||||
if( !ar )
|
||||
ar.message() << "Relative difference is within tolerance ["
|
||||
<< P.tested_rel_diff() << " < " << fpc_tolerance<FPT>() << ']';
|
||||
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -161,7 +155,12 @@ compare_fpv_near_zero( FPT const& fpv, op::GT<Lhs,Rhs>* )
|
||||
template<typename Lhs,typename Rhs> \
|
||||
struct name<Lhs,Rhs,typename boost::enable_if_c< \
|
||||
(fpc::tolerance_based<Lhs>::value && \
|
||||
fpc::tolerance_based<Rhs>::value)>::type> { \
|
||||
fpc::tolerance_based<Rhs>::value) || \
|
||||
(fpc::tolerance_based<Lhs>::value && \
|
||||
boost::is_arithmetic<Rhs>::value) || \
|
||||
(boost::is_arithmetic<Lhs>::value && \
|
||||
fpc::tolerance_based<Rhs>::value) \
|
||||
>::type> { \
|
||||
public: \
|
||||
typedef typename common_type<Lhs,Rhs>::type FPT; \
|
||||
typedef name<Lhs,Rhs> OP; \
|
||||
@@ -177,22 +176,13 @@ public: \
|
||||
static assertion_result \
|
||||
eval( Lhs const& lhs, Rhs const& rhs ) \
|
||||
{ \
|
||||
if( lhs == 0 ) \
|
||||
if( fpc_tolerance<FPT>() == FPT(0) \
|
||||
|| (std::numeric_limits<Lhs>::has_infinity \
|
||||
&& (lhs == std::numeric_limits<Lhs>::infinity())) \
|
||||
|| (std::numeric_limits<Rhs>::has_infinity \
|
||||
&& (rhs == std::numeric_limits<Rhs>::infinity()))) \
|
||||
{ \
|
||||
return compare_fpv_near_zero( rhs, (OP*)0 ); \
|
||||
} \
|
||||
\
|
||||
if( rhs == 0 ) \
|
||||
{ \
|
||||
return compare_fpv_near_zero( lhs, (OP*)0 ); \
|
||||
} \
|
||||
\
|
||||
bool direct_res = eval_direct( lhs, rhs ); \
|
||||
\
|
||||
if( (direct_res && fpctraits<OP>::cmp_direct) || \
|
||||
fpc_tolerance<FPT>() == FPT(0) ) \
|
||||
{ \
|
||||
return direct_res; \
|
||||
return eval_direct( lhs, rhs ); \
|
||||
} \
|
||||
\
|
||||
return compare_fpv<FPT>( lhs, rhs, (OP*)0 ); \
|
||||
@@ -227,4 +217,3 @@ BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_FPV_COMPARISON )
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_FPC_OP_HPP_050915GER
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ inline assertion_result equal_impl( char const* left, char* right ) { return equ
|
||||
inline assertion_result equal_impl( char* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
|
||||
#if !defined( BOOST_NO_CWCHAR )
|
||||
assertion_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right );
|
||||
BOOST_TEST_DECL assertion_result equal_impl( wchar_t const* left, wchar_t const* right );
|
||||
inline assertion_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
|
||||
inline assertion_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
|
||||
inline assertion_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); }
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <boost/preprocessor/seq/to_tuple.hpp>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -95,7 +97,7 @@ do {
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL ) \
|
||||
#define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL ) \
|
||||
do { \
|
||||
try { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
@@ -103,9 +105,9 @@ do {
|
||||
BOOST_TEST_TOOL_IMPL( 2, false, "exception " BOOST_STRINGIZE(E) " expected but not raised", \
|
||||
TL, CHECK_MSG, _ ); \
|
||||
} catch( E const& ex ) { \
|
||||
::boost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \
|
||||
BOOST_TEST_TOOL_IMPL( 2, P, \
|
||||
"exception \"" BOOST_STRINGIZE( E )"\" raised as expected" postfix, \
|
||||
boost::ignore_unused( ex ); \
|
||||
BOOST_TEST_TOOL_IMPL( 2, P, \
|
||||
"exception \"" BOOST_STRINGIZE( E )"\" raised as expected" postfix, \
|
||||
TL, CHECK_MSG, _ ); \
|
||||
} \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
|
||||
Reference in New Issue
Block a user