New upstream version 8.1.0
This commit is contained in:
410
thirdparty/source/boost_1_61_0/boost/test/tools/assertion.hpp
vendored
Normal file
410
thirdparty/source/boost_1_61_0/boost/test/tools/assertion.hpp
vendored
Normal file
@@ -0,0 +1,410 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief Defines framework for automated assertion construction
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_ASSERTION_HPP_100911GER
|
||||
#define BOOST_TEST_TOOLS_ASSERTION_HPP_100911GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
#include <boost/test/tools/detail/print_helper.hpp>
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
// STL
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace assertion {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion::operators ************** //
|
||||
// ************************************************************************** //
|
||||
// precedence 4: ->*, .*
|
||||
// precedence 5: *, /, %
|
||||
// precedence 6: +, -
|
||||
// precedence 7: << , >>
|
||||
// precedence 8: <, <=, > and >=
|
||||
// precedence 9: == and !=
|
||||
// precedence 10: bitwise AND
|
||||
// precedence 11: bitwise XOR
|
||||
// precedence 12: bitwise OR
|
||||
// precedence 13: logical AND
|
||||
// disabled
|
||||
// precedence 14: logical OR
|
||||
// disabled
|
||||
// precedence 15: ternary conditional
|
||||
// disabled
|
||||
// precedence 16: = and OP= operators
|
||||
// precedence 17: throw operator
|
||||
// not supported
|
||||
// precedence 18: comma
|
||||
// not supported
|
||||
|
||||
namespace op {
|
||||
|
||||
#define BOOST_TEST_FOR_EACH_COMP_OP(action) \
|
||||
action( < , LT, >= ) \
|
||||
action( <=, LE, > ) \
|
||||
action( > , GT, <= ) \
|
||||
action( >=, GE, < ) \
|
||||
action( ==, EQ, != ) \
|
||||
action( !=, NE, == ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_DECLTYPE
|
||||
|
||||
#define BOOST_TEST_FOR_EACH_CONST_OP(action)\
|
||||
action(->*, MEMP, ->* ) \
|
||||
\
|
||||
action( * , MUL, * ) \
|
||||
action( / , DIV, / ) \
|
||||
action( % , MOD, % ) \
|
||||
\
|
||||
action( + , ADD, + ) \
|
||||
action( - , SUB, - ) \
|
||||
\
|
||||
action( <<, LSH, << ) \
|
||||
action( >>, RSH, >> ) \
|
||||
\
|
||||
BOOST_TEST_FOR_EACH_COMP_OP(action) \
|
||||
\
|
||||
action( & , BAND, & ) \
|
||||
action( ^ , XOR, ^ ) \
|
||||
action( | , BOR, | ) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_TEST_FOR_EACH_CONST_OP(action)\
|
||||
BOOST_TEST_FOR_EACH_COMP_OP(action) \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_FOR_EACH_MUT_OP(action) \
|
||||
action( = , SET , = ) \
|
||||
action( +=, IADD, += ) \
|
||||
action( -=, ISUB, -= ) \
|
||||
action( *=, IMUL, *= ) \
|
||||
action( /=, IDIV, /= ) \
|
||||
action( %=, IMOD, %= ) \
|
||||
action(<<=, ILSH, <<=) \
|
||||
action(>>=, IRSH, >>=) \
|
||||
action( &=, IAND, &= ) \
|
||||
action( ^=, IXOR, ^= ) \
|
||||
action( |=, IOR , |= ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifndef BOOST_NO_CXX11_DECLTYPE
|
||||
# define DEDUCE_RESULT_TYPE( oper ) \
|
||||
decltype(boost::declval<Lhs>() oper boost::declval<Rhs>() ) optype; \
|
||||
typedef typename boost::remove_reference<optype>::type \
|
||||
/**/
|
||||
#else
|
||||
# define DEDUCE_RESULT_TYPE( oper ) bool
|
||||
#endif
|
||||
|
||||
#define DEFINE_CONST_OPER( oper, name, rev ) \
|
||||
template<typename Lhs, typename Rhs, \
|
||||
typename Enabler=void> \
|
||||
struct name { \
|
||||
typedef DEDUCE_RESULT_TYPE( oper ) result_type; \
|
||||
\
|
||||
static result_type \
|
||||
eval( Lhs const& lhs, Rhs const& rhs ) \
|
||||
{ \
|
||||
return lhs oper rhs; \
|
||||
} \
|
||||
\
|
||||
template<typename PrevExprType> \
|
||||
static void \
|
||||
report( std::ostream& ostr, \
|
||||
PrevExprType const& lhs, \
|
||||
Rhs const& rhs) \
|
||||
{ \
|
||||
lhs.report( ostr ); \
|
||||
ostr << revert() \
|
||||
<< tt_detail::print_helper( rhs ); \
|
||||
} \
|
||||
\
|
||||
static char const* revert() \
|
||||
{ return " " #rev " "; } \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_TEST_FOR_EACH_CONST_OP( DEFINE_CONST_OPER )
|
||||
|
||||
#undef DEDUCE_RESULT_TYPE
|
||||
#undef DEFINE_CONST_OPER
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace op
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion::expression_base ************** //
|
||||
// ************************************************************************** //
|
||||
// Defines expression operators
|
||||
|
||||
template<typename Lhs, typename Rhs, typename OP> class binary_expr;
|
||||
|
||||
template<typename ExprType,typename ValType>
|
||||
class expression_base {
|
||||
public:
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template<typename T>
|
||||
struct RhsT : remove_const<typename remove_reference<T>::type> {};
|
||||
|
||||
#define ADD_OP_SUPPORT( oper, name, _ ) \
|
||||
template<typename T> \
|
||||
binary_expr<ExprType,T, \
|
||||
op::name<ValType,typename RhsT<T>::type> > \
|
||||
operator oper( T&& rhs ) \
|
||||
{ \
|
||||
return binary_expr<ExprType,T, \
|
||||
op::name<ValType,typename RhsT<T>::type> > \
|
||||
( std::forward<ExprType>( \
|
||||
*static_cast<ExprType*>(this) ), \
|
||||
std::forward<T>(rhs) ); \
|
||||
} \
|
||||
/**/
|
||||
#else
|
||||
|
||||
#define ADD_OP_SUPPORT( oper, name, _ ) \
|
||||
template<typename T> \
|
||||
binary_expr<ExprType,typename boost::decay<T const>::type, \
|
||||
op::name<ValType,typename boost::decay<T const>::type> >\
|
||||
operator oper( T const& rhs ) const \
|
||||
{ \
|
||||
typedef typename boost::decay<T const>::type Rhs; \
|
||||
return binary_expr<ExprType,Rhs,op::name<ValType,Rhs> > \
|
||||
( *static_cast<ExprType const*>(this), \
|
||||
rhs ); \
|
||||
} \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
BOOST_TEST_FOR_EACH_CONST_OP( ADD_OP_SUPPORT )
|
||||
#undef ADD_OP_SUPPORT
|
||||
|
||||
#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
|
||||
// Disabled operators
|
||||
template<typename T>
|
||||
ExprType&
|
||||
operator ||( T const& /*rhs*/ )
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(false, CANT_USE_LOGICAL_OPERATOR_OR_WITHIN_THIS_TESTING_TOOL, () );
|
||||
|
||||
return *static_cast<ExprType*>(this);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ExprType&
|
||||
operator &&( T const& /*rhs*/ )
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(false, CANT_USE_LOGICAL_OPERATOR_AND_WITHIN_THIS_TESTING_TOOL, () );
|
||||
|
||||
return *static_cast<ExprType*>(this);
|
||||
}
|
||||
|
||||
operator bool()
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(false, CANT_USE_TERNARY_OPERATOR_WITHIN_THIS_TESTING_TOOL, () );
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion::value_expr ************** //
|
||||
// ************************************************************************** //
|
||||
// simple value expression
|
||||
|
||||
template<typename T>
|
||||
class value_expr : public expression_base<value_expr<T>,typename remove_const<typename remove_reference<T>::type>::type> {
|
||||
public:
|
||||
// Public types
|
||||
typedef T result_type;
|
||||
|
||||
// Constructor
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
value_expr( value_expr&& ve )
|
||||
: m_value( std::forward<T>(ve.m_value) )
|
||||
{}
|
||||
explicit value_expr( T&& val )
|
||||
: m_value( std::forward<T>(val) )
|
||||
{}
|
||||
#else
|
||||
explicit value_expr( T const& val )
|
||||
: m_value( val )
|
||||
{}
|
||||
#endif
|
||||
|
||||
// Specific expression interface
|
||||
T const& value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
void report( std::ostream& ostr ) const
|
||||
{
|
||||
ostr << tt_detail::print_helper( m_value );
|
||||
}
|
||||
|
||||
// Mutating operators
|
||||
#define ADD_OP_SUPPORT( OPER, ID, _ ) \
|
||||
template<typename U> \
|
||||
value_expr<T>& \
|
||||
operator OPER( U const& rhs ) \
|
||||
{ \
|
||||
m_value OPER rhs; \
|
||||
\
|
||||
return *this; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
BOOST_TEST_FOR_EACH_MUT_OP( ADD_OP_SUPPORT )
|
||||
#undef ADD_OP_SUPPORT
|
||||
|
||||
// expression interface
|
||||
assertion_result evaluate( bool no_message = false ) const
|
||||
{
|
||||
assertion_result res( value() );
|
||||
if( no_message || res )
|
||||
return res;
|
||||
|
||||
format_message( res.message(), value() );
|
||||
|
||||
return tt_detail::format_assertion_result( "", res.message().str() );
|
||||
}
|
||||
|
||||
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*/, assertion_result const& /*v*/ ) {}
|
||||
|
||||
// Data members
|
||||
T m_value;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion::binary_expr ************** //
|
||||
// ************************************************************************** //
|
||||
// binary expression
|
||||
|
||||
template<typename LExpr, typename Rhs, typename OP>
|
||||
class binary_expr : public expression_base<binary_expr<LExpr,Rhs,OP>,typename OP::result_type> {
|
||||
public:
|
||||
// Public types
|
||||
typedef typename OP::result_type result_type;
|
||||
|
||||
// Constructor
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
binary_expr( binary_expr&& be )
|
||||
: m_lhs( std::forward<LExpr>(be.m_lhs) )
|
||||
, m_rhs( std::forward<Rhs>(be.m_rhs) )
|
||||
{}
|
||||
binary_expr( LExpr&& lhs, Rhs&& rhs )
|
||||
: m_lhs( std::forward<LExpr>(lhs) )
|
||||
, m_rhs( std::forward<Rhs>(rhs) )
|
||||
{}
|
||||
#else
|
||||
binary_expr( LExpr const& lhs, Rhs const& rhs )
|
||||
: m_lhs( lhs )
|
||||
, m_rhs( rhs )
|
||||
{}
|
||||
#endif
|
||||
|
||||
// Specific expression interface
|
||||
result_type value() const
|
||||
{
|
||||
return OP::eval( m_lhs.value(), m_rhs );
|
||||
}
|
||||
void report( std::ostream& ostr ) const
|
||||
{
|
||||
return OP::report( ostr, m_lhs, m_rhs );
|
||||
}
|
||||
|
||||
assertion_result evaluate( bool no_message = false ) const
|
||||
{
|
||||
assertion_result const expr_res( value() );
|
||||
if( no_message || expr_res )
|
||||
return expr_res;
|
||||
|
||||
wrap_stringstream buff;
|
||||
report( buff.stream() );
|
||||
|
||||
return tt_detail::format_assertion_result( buff.stream().str(), expr_res.message() );
|
||||
}
|
||||
|
||||
// To support custom manipulators
|
||||
LExpr const& lhs() const { return m_lhs; }
|
||||
Rhs const& rhs() const { return m_rhs; }
|
||||
private:
|
||||
// Data members
|
||||
LExpr m_lhs;
|
||||
Rhs m_rhs;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion::seed ************** //
|
||||
// ************************************************************************** //
|
||||
// seed added ot the input expression to form an assertion expression
|
||||
|
||||
class seed {
|
||||
public:
|
||||
// ->* is highest precedence left to right operator
|
||||
template<typename T>
|
||||
value_expr<T>
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
operator->*( T&& v ) const
|
||||
{
|
||||
return value_expr<T>( std::forward<T>( v ) );
|
||||
}
|
||||
#else
|
||||
operator->*( T const& v ) const
|
||||
{
|
||||
return value_expr<T>( v );
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef BOOST_TEST_FOR_EACH_CONST_OP
|
||||
|
||||
} // namespace assertion
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_ASSERTION_HPP_100911GER
|
||||
90
thirdparty/source/boost_1_61_0/boost/test/tools/assertion_result.hpp
vendored
Normal file
90
thirdparty/source/boost_1_61_0/boost/test/tools/assertion_result.hpp
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
/// @file
|
||||
/// Enhanced result for test predicate that include message explaining failure
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|
||||
#define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/class_properties.hpp>
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion_result ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//!@brief Type used for storing the result of an assertion.
|
||||
class BOOST_TEST_DECL assertion_result {
|
||||
|
||||
//!@internal
|
||||
typedef unit_test::const_string const_string;
|
||||
|
||||
//!@internal
|
||||
struct dummy { void nonnull() {} };
|
||||
|
||||
//!@internal
|
||||
typedef void (dummy::*safe_bool)();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
assertion_result( bool pv_ )
|
||||
: p_predicate_value( pv_ )
|
||||
{}
|
||||
|
||||
template<typename BoolConvertable>
|
||||
assertion_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
|
||||
|
||||
// Access methods
|
||||
bool operator!() const { return !p_predicate_value; }
|
||||
void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
|
||||
operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
|
||||
|
||||
// Public properties
|
||||
BOOST_READONLY_PROPERTY( bool, (assertion_result) ) p_predicate_value;
|
||||
|
||||
// Access methods
|
||||
bool has_empty_message() const { return !m_message; }
|
||||
wrap_stringstream& message()
|
||||
{
|
||||
if( !m_message )
|
||||
m_message.reset( new wrap_stringstream );
|
||||
|
||||
return *m_message;
|
||||
}
|
||||
const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
shared_ptr<wrap_stringstream> m_message;
|
||||
};
|
||||
|
||||
typedef assertion_result predicate_result;
|
||||
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|
||||
378
thirdparty/source/boost_1_61_0/boost/test/tools/collection_comparison_op.hpp
vendored
Normal file
378
thirdparty/source/boost_1_61_0/boost/test/tools/collection_comparison_op.hpp
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief Collection comparison with enhanced reporting
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_COLLECTION_COMPARISON_OP_HPP_050815GER
|
||||
#define BOOST_TEST_TOOLS_COLLECTION_COMPARISON_OP_HPP_050815GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
|
||||
#include <boost/test/utils/is_forward_iterable.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace assertion {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************* selectors for specialized comparizon routines ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
struct specialized_compare : public mpl::false_ {};
|
||||
|
||||
#define BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(Col) \
|
||||
namespace boost { namespace test_tools { namespace assertion { \
|
||||
template<> \
|
||||
struct specialized_compare<Col> : public mpl::true_ {}; \
|
||||
}}} \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** lexicographic_compare ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace op {
|
||||
|
||||
template <typename OP, bool can_be_equal, bool prefer_shorter,
|
||||
typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
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;
|
||||
|
||||
for( ; (first1 != last1) && (first2 != last2); ++first1, ++first2, ++pos ) {
|
||||
assertion_result const& element_ar = OP::eval(*first1, *first2);
|
||||
if( !can_be_equal && element_ar )
|
||||
return ar; // a < b
|
||||
|
||||
assertion_result const& reverse_ar = OP::eval(*first2, *first1);
|
||||
if( element_ar && !reverse_ar )
|
||||
return ar; // a<=b and !(b<=a) => a < b => return true
|
||||
|
||||
if( element_ar || !reverse_ar )
|
||||
continue; // (a<=b and b<=a) or (!(a<b) and !(b<a)) => a == b => keep looking
|
||||
|
||||
// !(a<=b) and b<=a => b < a => return false
|
||||
ar = false;
|
||||
ar.message() << "\nFailure at position " << pos << ": "
|
||||
<< tt_detail::print_helper(*first1)
|
||||
<< OP::revert()
|
||||
<< tt_detail::print_helper(*first2)
|
||||
<< ". " << element_ar.message();
|
||||
return ar;
|
||||
}
|
||||
|
||||
|
||||
if( first1 != last1 ) {
|
||||
if( prefer_shorter ) {
|
||||
ar = false;
|
||||
ar.message() << "\nFirst collection has extra trailing elements.";
|
||||
}
|
||||
}
|
||||
else if( first2 != last2 ) {
|
||||
if( !prefer_shorter ) {
|
||||
ar = false;
|
||||
ar.message() << "\nSecond collection has extra trailing elements.";
|
||||
}
|
||||
}
|
||||
else if( !can_be_equal ) {
|
||||
ar = false;
|
||||
ar.message() << "\nCollections appear to be equal.";
|
||||
}
|
||||
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** equality_compare ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template <typename OP, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
element_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
assertion_result ar( true );
|
||||
|
||||
if( lhs.size() != rhs.size() ) {
|
||||
ar = false;
|
||||
ar.message() << "\nCollections size mismatch: " << lhs.size() << " != " << rhs.size();
|
||||
return ar;
|
||||
}
|
||||
|
||||
typename Lhs::const_iterator left = lhs.begin();
|
||||
typename Rhs::const_iterator right = rhs.begin();
|
||||
std::size_t pos = 0;
|
||||
|
||||
for( ; pos < lhs.size(); ++left, ++right, ++pos ) {
|
||||
assertion_result const element_ar = OP::eval( *left, *right );
|
||||
if( element_ar )
|
||||
continue;
|
||||
|
||||
ar = false;
|
||||
ar.message() << "\nMismatch at position " << pos << ": "
|
||||
<< tt_detail::print_helper(*left)
|
||||
<< OP::revert()
|
||||
<< tt_detail::print_helper(*right)
|
||||
<< ". " << element_ar.message();
|
||||
}
|
||||
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** non_equality_compare ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template <typename OP, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
non_equality_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
assertion_result ar( true );
|
||||
|
||||
if( lhs.size() != rhs.size() )
|
||||
return ar;
|
||||
|
||||
typename Lhs::const_iterator left = lhs.begin();
|
||||
typename Rhs::const_iterator right = rhs.begin();
|
||||
typename Lhs::const_iterator end = lhs.end();
|
||||
|
||||
for( ; left != end; ++left, ++right ) {
|
||||
if( OP::eval( *left, *right ) )
|
||||
return ar;
|
||||
}
|
||||
|
||||
ar = false;
|
||||
ar.message() << "\nCollections appear to be equal";
|
||||
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** cctraits ************** //
|
||||
// ************************************************************************** //
|
||||
// set of collection comparison traits per comparison OP
|
||||
|
||||
template<typename OP>
|
||||
struct cctraits;
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::EQ<Lhs, Rhs> > {
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::NE<Lhs, Rhs> > {
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::LT<Lhs, Rhs> > {
|
||||
static const bool can_be_equal = false;
|
||||
static const bool prefer_short = true;
|
||||
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::LE<Lhs, Rhs> > {
|
||||
static const bool can_be_equal = true;
|
||||
static const bool prefer_short = true;
|
||||
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::GT<Lhs, Rhs> > {
|
||||
static const bool can_be_equal = false;
|
||||
static const bool prefer_short = false;
|
||||
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct cctraits<op::GE<Lhs, Rhs> > {
|
||||
static const bool can_be_equal = true;
|
||||
static const bool prefer_short = false;
|
||||
|
||||
typedef specialized_compare<Lhs> is_specialized;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** compare_collections ************** //
|
||||
// ************************************************************************** //
|
||||
// Overloaded set of functions dispatching to specific implementation of comparison
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::EQ<L, R> >*, mpl::true_ )
|
||||
{
|
||||
return assertion::op::element_compare<op::EQ<L, R> >( lhs, rhs );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::EQ<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::NE<L, R> >*, mpl::true_ )
|
||||
{
|
||||
return assertion::op::non_equality_compare<op::NE<L, R> >( lhs, rhs );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::NE<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs != rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename OP, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
lexicographic_compare( Lhs const& lhs, Rhs const& rhs )
|
||||
{
|
||||
return assertion::op::lexicographic_compare<OP, cctraits<OP>::can_be_equal, cctraits<OP>::prefer_short>( lhs, rhs );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename OP>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<OP>*, mpl::true_ )
|
||||
{
|
||||
return lexicographic_compare<OP>( lhs, rhs );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::LT<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs < rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::LE<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs <= rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GT<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs > rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename Lhs, typename Rhs, typename L, typename R>
|
||||
inline assertion_result
|
||||
compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GE<L, R> >*, mpl::false_ )
|
||||
{
|
||||
return lhs >= rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ********* specialization of comparison operators for collections ********* //
|
||||
// ************************************************************************** //
|
||||
|
||||
#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_forward_iterable<Rhs>::value>::type> { \
|
||||
public: \
|
||||
typedef assertion_result result_type; \
|
||||
\
|
||||
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; \
|
||||
\
|
||||
static assertion_result \
|
||||
eval( Lhs const& lhs, Rhs const& rhs) \
|
||||
{ \
|
||||
return assertion::op::compare_collections( lhs, rhs, \
|
||||
(boost::type<elem_op>*)0, \
|
||||
is_specialized() ); \
|
||||
} \
|
||||
\
|
||||
template<typename PrevExprType> \
|
||||
static void \
|
||||
report( std::ostream&, \
|
||||
PrevExprType const&, \
|
||||
Rhs const& ) {} \
|
||||
\
|
||||
static char const* revert() \
|
||||
{ return " " #rev " "; } \
|
||||
\
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_COLLECTION_COMPARISON )
|
||||
#undef DEFINE_COLLECTION_COMPARISON
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace op
|
||||
} // namespace assertion
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_COLLECTION_COMPARISON_OP_HPP_050815GER
|
||||
65
thirdparty/source/boost_1_61_0/boost/test/tools/context.hpp
vendored
Normal file
65
thirdparty/source/boost_1_61_0/boost/test/tools/context.hpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : test tools context interfaces
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
|
||||
#define BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/lazy_ostream.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** context_frame ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct BOOST_TEST_DECL context_frame {
|
||||
explicit context_frame( ::boost::unit_test::lazy_ostream const& context_descr );
|
||||
~context_frame();
|
||||
|
||||
operator bool();
|
||||
|
||||
private:
|
||||
// Data members
|
||||
int m_frame_id;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_INFO( context_descr ) \
|
||||
::boost::unit_test::framework::add_context( BOOST_TEST_LAZY_MSG( context_descr ) , false ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#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 ) ) ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
|
||||
91
thirdparty/source/boost_1_61_0/boost/test/tools/cstring_comparison_op.hpp
vendored
Normal file
91
thirdparty/source/boost_1_61_0/boost/test/tools/cstring_comparison_op.hpp
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief C string comparison with enhanced reporting
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
|
||||
#define BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
|
||||
#include <boost/test/utils/is_cstring.hpp>
|
||||
#include <boost/test/utils/basic_cstring/compare.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace assertion {
|
||||
namespace op {
|
||||
|
||||
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** string_compare ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#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>::type> { \
|
||||
typedef typename boost::add_const< \
|
||||
typename remove_pointer< \
|
||||
typename decay<Lhs>::type>::type>::type \
|
||||
lhs_char_type; \
|
||||
typedef typename boost::add_const< \
|
||||
typename remove_pointer< \
|
||||
typename decay<Rhs>::type>::type>::type \
|
||||
rhs_char_type; \
|
||||
public: \
|
||||
typedef assertion_result result_type; \
|
||||
\
|
||||
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); \
|
||||
} \
|
||||
\
|
||||
template<typename PrevExprType> \
|
||||
static void \
|
||||
report( std::ostream& ostr, \
|
||||
PrevExprType const& lhs, \
|
||||
Rhs const& rhs) \
|
||||
{ \
|
||||
lhs.report( ostr ); \
|
||||
ostr << revert() \
|
||||
<< tt_detail::print_helper( rhs ); \
|
||||
} \
|
||||
\
|
||||
static char const* revert() \
|
||||
{ return " " #rev " "; } \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_CSTRING_COMPARISON )
|
||||
#undef DEFINE_CSTRING_COMPARISON
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace op
|
||||
} // namespace assertion
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_CSTRING_COMPARISON_OP_HPP_050815GER
|
||||
|
||||
123
thirdparty/source/boost_1_61_0/boost/test/tools/detail/bitwise_manip.hpp
vendored
Normal file
123
thirdparty/source/boost_1_61_0/boost/test/tools/detail/bitwise_manip.hpp
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//! @file
|
||||
//! Bitwise comparison manipulator implementation
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_BITWISE_MANIP_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_BITWISE_MANIP_HPP_012705GER
|
||||
|
||||
// Boost Test
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
#include <boost/test/tools/detail/indirections.hpp>
|
||||
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
|
||||
// STL
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** bitwise comparison manipulator ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//! Bitwise comparison manipulator
|
||||
struct bitwise {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline int
|
||||
operator<<( unit_test::lazy_ostream const&, bitwise ) { return 0; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
/*!@brief Bitwise comparison of two operands
|
||||
*
|
||||
* This class constructs an @ref assertion_result that contains precise bit comparison information.
|
||||
* In particular the location of the mismatches (if any) are printed in the assertion result.
|
||||
*/
|
||||
template<typename Lhs, typename Rhs, typename E>
|
||||
inline assertion_result
|
||||
bitwise_compare(Lhs const& lhs, Rhs const& rhs, E const& expr )
|
||||
{
|
||||
assertion_result pr( true );
|
||||
|
||||
std::size_t left_bit_size = sizeof(Lhs)*CHAR_BIT;
|
||||
std::size_t right_bit_size = sizeof(Rhs)*CHAR_BIT;
|
||||
|
||||
static Lhs const leftOne( 1 );
|
||||
static Rhs const rightOne( 1 );
|
||||
|
||||
std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size;
|
||||
|
||||
for( std::size_t counter = 0; counter < total_bits; ++counter ) {
|
||||
if( (lhs & ( leftOne << counter )) != (rhs & (rightOne << counter)) ) {
|
||||
if( pr ) {
|
||||
pr.message() << " [";
|
||||
expr.report( pr.message().stream() );
|
||||
pr.message() << "]. Bitwise comparison failed";
|
||||
pr = false;
|
||||
}
|
||||
pr.message() << "\nMismatch at position " << counter;
|
||||
}
|
||||
}
|
||||
|
||||
if( left_bit_size != right_bit_size ) {
|
||||
if( pr ) {
|
||||
pr.message() << " [";
|
||||
expr.report( pr.message().stream() );
|
||||
pr.message() << "]. Bitwise comparison failed";
|
||||
pr = false;
|
||||
}
|
||||
pr.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size;
|
||||
}
|
||||
|
||||
return pr;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
//! Returns an assertion_result using the bitwise comparison out of an expression
|
||||
//!
|
||||
//! This is used as a modifer of the normal operator<< on expressions to use the
|
||||
//! bitwise comparison.
|
||||
//!
|
||||
//! @note Available only for compilers supporting the @c auto declaration.
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
inline assertion_result
|
||||
operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,assertion::op::EQ<T3,T4> > > const& ae, bitwise )
|
||||
{
|
||||
return bitwise_compare( ae.m_e.lhs().value(), ae.m_e.rhs(), ae.m_e );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline check_type
|
||||
operator<<( assertion_type const& , bitwise )
|
||||
{
|
||||
return CHECK_BUILT_ASSERTION;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_BITWISE_MANIP_HPP_012705GER
|
||||
70
thirdparty/source/boost_1_61_0/boost/test/tools/detail/expression_holder.hpp
vendored
Normal file
70
thirdparty/source/boost_1_61_0/boost/test/tools/detail/expression_holder.hpp
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : toolbox implementation details
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER
|
||||
|
||||
#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tt_detail::expression_holder ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class expression_holder {
|
||||
public:
|
||||
virtual ~expression_holder() {}
|
||||
virtual assertion_result evaluate( bool no_message = false ) const = 0;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename E>
|
||||
class expression_holder_t: public expression_holder {
|
||||
public:
|
||||
explicit expression_holder_t( E const& e ) : m_expr( e ) {}
|
||||
|
||||
private:
|
||||
virtual assertion_result evaluate( bool no_message = false ) const { return m_expr.evaluate( no_message ); }
|
||||
|
||||
E m_expr;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename E>
|
||||
expression_holder_t<E>
|
||||
hold_expression( E const& e )
|
||||
{
|
||||
return expression_holder_t<E>( e );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER
|
||||
121
thirdparty/source/boost_1_61_0/boost/test/tools/detail/fwd.hpp
vendored
Normal file
121
thirdparty/source/boost_1_61_0/boost/test/tools/detail/fwd.hpp
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : toolbox implementation types and forward declarations
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_FWD_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_FWD_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace unit_test {
|
||||
|
||||
class lazy_ostream;
|
||||
|
||||
} // namespace unit_test
|
||||
|
||||
namespace test_tools {
|
||||
|
||||
using unit_test::const_string;
|
||||
class assertion_result;
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
inline bool dummy_cond() { return false; }
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** types of supported assertions ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
enum check_type {
|
||||
CHECK_PRED,
|
||||
CHECK_MSG,
|
||||
CHECK_EQUAL,
|
||||
CHECK_NE,
|
||||
CHECK_LT,
|
||||
CHECK_LE,
|
||||
CHECK_GT,
|
||||
CHECK_GE,
|
||||
CHECK_CLOSE,
|
||||
CHECK_CLOSE_FRACTION,
|
||||
CHECK_SMALL,
|
||||
CHECK_BITWISE_EQUAL,
|
||||
CHECK_PRED_WITH_ARGS,
|
||||
CHECK_EQUAL_COLL,
|
||||
CHECK_BUILT_ASSERTION
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** levels of supported assertions ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
enum tool_level {
|
||||
WARN, CHECK, REQUIRE, PASS
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** Tools offline implementation ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
BOOST_TEST_DECL bool
|
||||
report_assertion( assertion_result const& pr, unit_test::lazy_ostream const& assertion_descr,
|
||||
const_string file_name, std::size_t line_num,
|
||||
tool_level tl, check_type ct,
|
||||
std::size_t num_args, ... );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_TEST_DECL assertion_result
|
||||
format_assertion_result( const_string expr_val, const_string details );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_TEST_DECL assertion_result
|
||||
format_fpc_report( const_string expr_val, const_string details );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_TEST_DECL bool
|
||||
is_defined_impl( const_string symbol_name, const_string symbol_value );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
BOOST_TEST_DECL assertion_result
|
||||
equal_impl( char const* left, char const* right );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_FWD_HPP_012705GER
|
||||
94
thirdparty/source/boost_1_61_0/boost/test/tools/detail/indirections.hpp
vendored
Normal file
94
thirdparty/source/boost_1_61_0/boost/test/tools/detail/indirections.hpp
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : inidiration interfaces to support manipulators and message output
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion_evaluate indirection ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename E>
|
||||
struct assertion_evaluate_t {
|
||||
assertion_evaluate_t( E const& e ) : m_e( e ) {}
|
||||
operator assertion_result() { return m_e.evaluate( true ); }
|
||||
|
||||
E const& m_e;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename E>
|
||||
inline assertion_evaluate_t<E>
|
||||
assertion_evaluate( E const& e ) { return assertion_evaluate_t<E>( e ); }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename E, typename T>
|
||||
inline assertion_evaluate_t<E>
|
||||
operator<<( assertion_evaluate_t<E> const& ae, T const& ) { return ae; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion_text indirection ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
inline unit_test::lazy_ostream const&
|
||||
assertion_text( unit_test::lazy_ostream const& /*et*/, T const& m ) { return m; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline unit_test::lazy_ostream const&
|
||||
assertion_text( unit_test::lazy_ostream const& et, int ) { return et; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** assertion_evaluate indirection ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct assertion_type {
|
||||
operator check_type() { return CHECK_MSG; }
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
inline assertion_type
|
||||
operator<<( assertion_type const& at, T const& ) { return at; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
|
||||
74
thirdparty/source/boost_1_61_0/boost/test/tools/detail/it_pair.hpp
vendored
Normal file
74
thirdparty/source/boost_1_61_0/boost/test/tools/detail/it_pair.hpp
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : support for backward compatible collection comparison interface
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER
|
||||
|
||||
#ifdef BOOST_TEST_NO_OLD_TOOLS
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** backward compatibility support ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename It>
|
||||
struct it_pair {
|
||||
typedef It const_iterator;
|
||||
typedef typename std::iterator_traits<It>::value_type value_type;
|
||||
|
||||
it_pair( It const& b, It const& e ) : m_begin( b ), m_size( 0 )
|
||||
{
|
||||
It tmp = b;
|
||||
while( tmp != e ) { ++m_size; ++tmp; }
|
||||
}
|
||||
|
||||
It begin() const { return m_begin; }
|
||||
It end() const { return m_begin + m_size; }
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
private:
|
||||
It m_begin;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename It>
|
||||
it_pair<It>
|
||||
make_it_pair( It const& b, It const& e ) { return it_pair<It>( b, e ); }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
it_pair<T const*>
|
||||
make_it_pair( T const* b, T const* e ) { return it_pair<T const*>( b, e ); }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_NO_OLD_TOOLS
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_IT_PAIR_HPP_112812GER
|
||||
69
thirdparty/source/boost_1_61_0/boost/test/tools/detail/lexicographic_manip.hpp
vendored
Normal file
69
thirdparty/source/boost_1_61_0/boost/test/tools/detail/lexicographic_manip.hpp
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//! @file
|
||||
//! Lexicographic comparison manipulator implementation
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
|
||||
|
||||
// Boost Test
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
#include <boost/test/tools/detail/indirections.hpp>
|
||||
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
#include <boost/test/tools/collection_comparison_op.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** per element comparison manipulator ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//! Lexicographic comparison manipulator, for containers
|
||||
struct lexicographic {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline int
|
||||
operator<<( unit_test::lazy_ostream const&, lexicographic ) { return 0; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
template<typename T1, typename T2, typename OP>
|
||||
inline assertion_result
|
||||
operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, lexicographic )
|
||||
{
|
||||
typedef typename OP::elem_op elem_op;
|
||||
return assertion::op::lexicographic_compare<elem_op>( ae.m_e.lhs().value(), ae.m_e.rhs() );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline check_type
|
||||
operator<<( assertion_type const&, lexicographic )
|
||||
{
|
||||
return CHECK_BUILT_ASSERTION;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_LEXICOGRAPHIC_MANIP_HPP_050815GER
|
||||
69
thirdparty/source/boost_1_61_0/boost/test/tools/detail/per_element_manip.hpp
vendored
Normal file
69
thirdparty/source/boost_1_61_0/boost/test/tools/detail/per_element_manip.hpp
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//! @file
|
||||
//! Per element comparison manipulator implementation
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_PER_ELEMENT_MANIP_HPP_050815GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_PER_ELEMENT_MANIP_HPP_050815GER
|
||||
|
||||
// Boost Test
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
#include <boost/test/tools/detail/indirections.hpp>
|
||||
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
#include <boost/test/tools/collection_comparison_op.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** per element comparison manipulator ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//! Per element comparison manipulator, for containers
|
||||
struct per_element {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline int
|
||||
operator<<( unit_test::lazy_ostream const&, per_element ) { return 0; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
template<typename T1, typename T2, typename OP>
|
||||
inline assertion_result
|
||||
operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, per_element )
|
||||
{
|
||||
typedef typename OP::elem_op elem_op;
|
||||
return assertion::op::element_compare<elem_op>( ae.m_e.lhs().value(), ae.m_e.rhs() );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline check_type
|
||||
operator<<( assertion_type const&, per_element )
|
||||
{
|
||||
return CHECK_BUILT_ASSERTION;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_PER_ELEMENT_MANIP_HPP_050815GER
|
||||
205
thirdparty/source/boost_1_61_0/boost/test/tools/detail/print_helper.hpp
vendored
Normal file
205
thirdparty/source/boost_1_61_0/boost/test/tools/detail/print_helper.hpp
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : defines level of indiration facilitating workarounds for non printable types
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_IMPL_COMMON_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_IMPL_COMMON_HPP_012705GER
|
||||
|
||||
// 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>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#include <boost/type_traits/has_left_shift.hpp>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** print_log_value ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
struct print_log_value {
|
||||
BOOST_STATIC_ASSERT_MSG( (boost::has_left_shift<std::ostream,T>::value),
|
||||
"Type has to implement operator<< to be printable");
|
||||
|
||||
void operator()( std::ostream& ostr, T const& t )
|
||||
{
|
||||
typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;
|
||||
|
||||
std::streamsize old_precision = set_precision( ostr, cant_use_nl() );
|
||||
|
||||
ostr << t;
|
||||
|
||||
if( old_precision != (std::streamsize)-1 )
|
||||
ostr.precision( old_precision );
|
||||
}
|
||||
|
||||
std::streamsize set_precision( std::ostream& ostr, mpl::false_ )
|
||||
{
|
||||
if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
|
||||
return ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
|
||||
else if ( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 ) {
|
||||
#ifdef BOOST_NO_CXX11_NUMERIC_LIMITS
|
||||
// (was BOOST_NO_NUMERIC_LIMITS_LOWEST but now deprecated).
|
||||
// No support for std::numeric_limits<double>::max_digits10,
|
||||
// so guess that a couple of guard digits more than digits10 will display any difference.
|
||||
return ostr.precision( 2 + std::numeric_limits<T>::digits10 );
|
||||
#else
|
||||
// std::numeric_limits<double>::max_digits10; IS supported.
|
||||
// Any noisy or guard digits needed to display any difference are included in max_digits10.
|
||||
return ostr.precision( std::numeric_limits<T>::max_digits10 );
|
||||
#endif
|
||||
}
|
||||
// else if T is not specialized for std::numeric_limits<>,
|
||||
// then will just get the default precision of 6 digits.
|
||||
return (std::streamsize)-1;
|
||||
}
|
||||
|
||||
std::streamsize set_precision( std::ostream&, mpl::true_ ) { return (std::streamsize)-1; }
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
template<typename T, std::size_t N >
|
||||
struct print_log_value< T[N] > {
|
||||
void operator()( std::ostream& ostr, T const* t )
|
||||
{
|
||||
ostr << t;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<bool> {
|
||||
void operator()( std::ostream& ostr, bool t )
|
||||
{
|
||||
ostr << std::boolalpha << t;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<char> {
|
||||
void operator()( std::ostream& ostr, char t );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<unsigned char> {
|
||||
void operator()( std::ostream& ostr, unsigned char t );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<char const*> {
|
||||
void operator()( std::ostream& ostr, char const* t );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct BOOST_TEST_DECL print_log_value<wchar_t const*> {
|
||||
void operator()( std::ostream& ostr, wchar_t const* t );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** print_helper ************** //
|
||||
// ************************************************************************** //
|
||||
// Adds level of indirection to the output operation, allowing us to customize
|
||||
// it for types that do not support operator << directly or for any other reason
|
||||
|
||||
template<typename T>
|
||||
struct print_helper_t {
|
||||
explicit print_helper_t( T const& t ) : m_t( t ) {}
|
||||
|
||||
T const& m_t;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// Borland suffers premature pointer decay passing arrays by reference
|
||||
template<typename T, std::size_t N >
|
||||
struct print_helper_t< T[N] > {
|
||||
explicit print_helper_t( T const * t ) : m_t( t ) {}
|
||||
|
||||
T const * m_t;
|
||||
};
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
inline print_helper_t<T>
|
||||
print_helper( T const& t )
|
||||
{
|
||||
return print_helper_t<T>( t );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
inline std::ostream&
|
||||
operator<<( std::ostream& ostr, print_helper_t<T> const& ph )
|
||||
{
|
||||
print_log_value<T>()( ostr, ph.m_t );
|
||||
|
||||
return ostr;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_DONT_PRINT_LOG_VALUE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
|
||||
namespace boost{ namespace test_tools{ namespace tt_detail{ \
|
||||
template<> \
|
||||
struct print_log_value<the_type > { \
|
||||
void operator()( std::ostream&, the_type const& ) {} \
|
||||
}; \
|
||||
}}} \
|
||||
/**/
|
||||
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_IMPL_COMMON_HPP_012705GER
|
||||
130
thirdparty/source/boost_1_61_0/boost/test/tools/detail/tolerance_manip.hpp
vendored
Normal file
130
thirdparty/source/boost_1_61_0/boost/test/tools/detail/tolerance_manip.hpp
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//! @file
|
||||
//! @brief Floating point comparison tolerance manipulators
|
||||
//!
|
||||
//! This file defines several manipulators for floating point comparison. These
|
||||
//! manipulators are intended to be used with BOOST_TEST.
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_TOLERANCE_MANIP_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_DETAIL_TOLERANCE_MANIP_HPP_012705GER
|
||||
|
||||
// Boost Test
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
#include <boost/test/tools/detail/indirections.hpp>
|
||||
|
||||
#include <boost/test/tools/fpc_tolerance.hpp>
|
||||
#include <boost/test/tools/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** fpc tolerance manipulator ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename FPT>
|
||||
struct tolerance_manip {
|
||||
explicit tolerance_manip( FPT const & tol ) : m_value( tol ) {}
|
||||
|
||||
FPT m_value;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct tolerance_manip_delay {};
|
||||
|
||||
template<typename FPT>
|
||||
inline tolerance_manip<FPT>
|
||||
operator%( FPT v, tolerance_manip_delay const& )
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG( (fpc::tolerance_based<FPT>::value),
|
||||
"tolerance should be specified using a floating points type" );
|
||||
|
||||
return tolerance_manip<FPT>( FPT(v / 100) );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename E, typename FPT>
|
||||
inline assertion_result
|
||||
operator<<(assertion_evaluate_t<E> const& ae, tolerance_manip<FPT> const& tol)
|
||||
{
|
||||
local_fpc_tolerance<FPT> lt( tol.m_value );
|
||||
|
||||
return ae.m_e.evaluate();
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline int
|
||||
operator<<( unit_test::lazy_ostream const&, tolerance_manip<FPT> const& ) { return 0; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline check_type
|
||||
operator<<( assertion_type const& /*at*/, tolerance_manip<FPT> const& ) { return CHECK_BUILT_ASSERTION; }
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
|
||||
/*! Tolerance manipulator
|
||||
*
|
||||
* These functions return a manipulator that can be used in conjunction with BOOST_TEST
|
||||
* in order to specify the tolerance with which floating point comparisons are made.
|
||||
*/
|
||||
template<typename FPT>
|
||||
inline tt_detail::tolerance_manip<FPT>
|
||||
tolerance( FPT v )
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG( (fpc::tolerance_based<FPT>::value),
|
||||
"tolerance only for floating points" );
|
||||
|
||||
return tt_detail::tolerance_manip<FPT>( v );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
//! @overload tolerance( FPT v )
|
||||
template<typename FPT>
|
||||
inline tt_detail::tolerance_manip<FPT>
|
||||
tolerance( fpc::percent_tolerance_t<FPT> v )
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG( (fpc::tolerance_based<FPT>::value),
|
||||
"tolerance only for floating points" );
|
||||
|
||||
return tt_detail::tolerance_manip<FPT>( static_cast<FPT>(v.m_value / 100) );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
//! @overload tolerance( FPT v )
|
||||
inline tt_detail::tolerance_manip_delay
|
||||
tolerance()
|
||||
{
|
||||
return tt_detail::tolerance_manip_delay();
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_DETAIL_TOLERANCE_MANIP_HPP_012705GER
|
||||
315
thirdparty/source/boost_1_61_0/boost/test/tools/floating_point_comparison.hpp
vendored
Normal file
315
thirdparty/source/boost_1_61_0/boost/test/tools/floating_point_comparison.hpp
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief algorithms for comparing floating point values
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
|
||||
#define BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/is_floating_point.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
// STL
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace math {
|
||||
namespace fpc {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** fpc::tolerance_based ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
|
||||
//! @internal
|
||||
//! Protects the instanciation of std::numeric_limits from non-supported types (eg. T=array)
|
||||
template <typename T, bool enabled>
|
||||
struct tolerance_based_delegate;
|
||||
|
||||
template <typename T>
|
||||
struct tolerance_based_delegate<T, false> : mpl::false_ {};
|
||||
|
||||
template <typename T>
|
||||
struct tolerance_based_delegate<T, true>
|
||||
: mpl::bool_<
|
||||
is_floating_point<T>::value ||
|
||||
(!std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_specialized && !std::numeric_limits<T>::is_exact)>
|
||||
{};
|
||||
|
||||
|
||||
/*!@brief Indicates if a type can be compared using a tolerance scheme
|
||||
*
|
||||
* This is a metafunction that should evaluate to @c mpl::true_ if the type
|
||||
* @c T can be compared using a tolerance based method, typically for floating point
|
||||
* types.
|
||||
*
|
||||
* This metafunction can be specialized further to declare user types that are
|
||||
* floating point (eg. boost.multiprecision).
|
||||
*/
|
||||
template <typename T>
|
||||
struct tolerance_based : tolerance_based_delegate<T, !is_array<T>::value >::type {};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** fpc::strength ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//! Method for comparing floating point numbers
|
||||
enum strength {
|
||||
FPC_STRONG, //!< "Very close" - equation 2' in docs, the default
|
||||
FPC_WEAK //!< "Close enough" - equation 3' in docs.
|
||||
};
|
||||
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tolerance presentation types ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename FPT>
|
||||
struct percent_tolerance_t {
|
||||
explicit percent_tolerance_t( FPT v ) : m_value( v ) {}
|
||||
|
||||
FPT m_value;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline std::ostream& operator<<( std::ostream& out, percent_tolerance_t<FPT> t )
|
||||
{
|
||||
return out << t.m_value;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline percent_tolerance_t<FPT>
|
||||
percent_tolerance( FPT v )
|
||||
{
|
||||
return percent_tolerance_t<FPT>( v );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** details ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace fpc_detail {
|
||||
|
||||
// FPT is Floating-Point Type: float, double, long double or User-Defined.
|
||||
template<typename FPT>
|
||||
inline FPT
|
||||
fpt_abs( FPT fpv )
|
||||
{
|
||||
return fpv < static_cast<FPT>(0) ? -fpv : fpv;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
struct fpt_specialized_limits
|
||||
{
|
||||
static FPT min_value() { return (std::numeric_limits<FPT>::min)(); }
|
||||
static FPT max_value() { return (std::numeric_limits<FPT>::max)(); }
|
||||
};
|
||||
|
||||
template<typename FPT>
|
||||
struct fpt_non_specialized_limits
|
||||
{
|
||||
static FPT min_value() { return static_cast<FPT>(0); }
|
||||
static FPT max_value() { return static_cast<FPT>(1000000); } // for our purposes it doesn't really matter what value is returned here
|
||||
};
|
||||
|
||||
template<typename FPT>
|
||||
struct fpt_limits : boost::conditional<std::numeric_limits<FPT>::is_specialized,
|
||||
fpt_specialized_limits<FPT>,
|
||||
fpt_non_specialized_limits<FPT>
|
||||
>::type
|
||||
{};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// both f1 and f2 are unsigned here
|
||||
template<typename FPT>
|
||||
inline FPT
|
||||
safe_fpt_division( FPT f1, FPT f2 )
|
||||
{
|
||||
// Avoid overflow.
|
||||
if( (f2 < static_cast<FPT>(1)) && (f1 > f2*fpt_limits<FPT>::max_value()) )
|
||||
return fpt_limits<FPT>::max_value();
|
||||
|
||||
// Avoid underflow.
|
||||
if( (f1 == static_cast<FPT>(0)) ||
|
||||
((f2 > static_cast<FPT>(1)) && (f1 < f2*fpt_limits<FPT>::min_value())) )
|
||||
return static_cast<FPT>(0);
|
||||
|
||||
return f1/f2;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT, typename ToleranceType>
|
||||
inline FPT
|
||||
fraction_tolerance( ToleranceType tolerance )
|
||||
{
|
||||
return static_cast<FPT>(tolerance);
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT2, typename FPT>
|
||||
inline FPT2
|
||||
fraction_tolerance( percent_tolerance_t<FPT> tolerance )
|
||||
{
|
||||
return FPT2(tolerance.m_value)*FPT2(0.01);
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace fpc_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** close_at_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
|
||||
* 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.
|
||||
*/
|
||||
template<typename FPT>
|
||||
class close_at_tolerance {
|
||||
public:
|
||||
// Public typedefs
|
||||
typedef bool result_type;
|
||||
|
||||
// Constructor
|
||||
template<typename ToleranceType>
|
||||
explicit close_at_tolerance( ToleranceType tolerance, fpc::strength fpc_strength = FPC_STRONG )
|
||||
: m_fraction_tolerance( fpc_detail::fraction_tolerance<FPT>( tolerance ) )
|
||||
, m_strength( fpc_strength )
|
||||
, m_tested_rel_diff( 0 )
|
||||
{
|
||||
BOOST_ASSERT_MSG( m_fraction_tolerance >= FPT(0), "tolerance must not be negative!" ); // no reason for tolerance to be negative
|
||||
}
|
||||
|
||||
// Access methods
|
||||
//! Returns the tolerance
|
||||
FPT fraction_tolerance() const { return m_fraction_tolerance; }
|
||||
|
||||
//! Returns the comparison method
|
||||
fpc::strength strength() const { return m_strength; }
|
||||
|
||||
//! Returns the failing fraction
|
||||
FPT tested_rel_diff() const { return m_tested_rel_diff; }
|
||||
|
||||
/*! Compares two floating point numbers a and b such that their "left" relative difference |a-b|/a and/or
|
||||
* "right" relative difference |a-b|/b does not exceed specified relative (fraction) tolerance.
|
||||
*
|
||||
* @param[in] left first floating point number to be compared
|
||||
* @param[in] right second floating point number to be compared
|
||||
*
|
||||
* What is reported by @c tested_rel_diff in case of failure depends on the comparison method:
|
||||
* - for @c FPC_STRONG: the max of the two fractions
|
||||
* - for @c FPC_WEAK: the min of the two fractions
|
||||
* The rationale behind is to report the tolerance to set in order to make a test pass.
|
||||
*/
|
||||
bool operator()( FPT left, FPT right ) const
|
||||
{
|
||||
FPT diff = fpc_detail::fpt_abs<FPT>( left - right );
|
||||
FPT fraction_of_right = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( right ) );
|
||||
FPT fraction_of_left = fpc_detail::safe_fpt_division( diff, fpc_detail::fpt_abs( left ) );
|
||||
|
||||
FPT max_rel_diff = (std::max)( fraction_of_left, fraction_of_right );
|
||||
FPT min_rel_diff = (std::min)( fraction_of_left, fraction_of_right );
|
||||
|
||||
m_tested_rel_diff = m_strength == FPC_STRONG ? max_rel_diff : min_rel_diff;
|
||||
|
||||
return m_tested_rel_diff <= m_fraction_tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
// Data members
|
||||
FPT m_fraction_tolerance;
|
||||
fpc::strength m_strength;
|
||||
mutable FPT m_tested_rel_diff;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** small_with_tolerance ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
|
||||
/*!@brief Predicate for comparing floating point numbers against 0
|
||||
*
|
||||
* Serves the same purpose as boost::math::fpc::close_at_tolerance, but used when one
|
||||
* of the operand is null.
|
||||
*/
|
||||
template<typename FPT>
|
||||
class small_with_tolerance {
|
||||
public:
|
||||
// Public typedefs
|
||||
typedef bool result_type;
|
||||
|
||||
// Constructor
|
||||
explicit small_with_tolerance( FPT tolerance ) // <= absolute tolerance
|
||||
: m_tolerance( tolerance )
|
||||
{
|
||||
BOOST_ASSERT( m_tolerance >= FPT(0) ); // no reason for the tolerance to be negative
|
||||
}
|
||||
|
||||
// Action method
|
||||
bool operator()( FPT fpv ) const
|
||||
{
|
||||
return fpc::fpc_detail::fpt_abs( fpv ) <= m_tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
// Data members
|
||||
FPT m_tolerance;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** is_small ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename FPT>
|
||||
inline bool
|
||||
is_small( FPT fpv, FPT tolerance )
|
||||
{
|
||||
return small_with_tolerance<FPT>( tolerance )( fpv );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace fpc
|
||||
} // namespace math
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_FLOATING_POINT_COMAPARISON_HPP_071894GER
|
||||
224
thirdparty/source/boost_1_61_0/boost/test/tools/fpc_op.hpp
vendored
Normal file
224
thirdparty/source/boost_1_61_0/boost/test/tools/fpc_op.hpp
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief Floating point comparison with enhanced reporting
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_FPC_OP_HPP_050915GER
|
||||
#define BOOST_TEST_TOOLS_FPC_OP_HPP_050915GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/assertion.hpp>
|
||||
|
||||
#include <boost/test/tools/floating_point_comparison.hpp>
|
||||
#include <boost/test/tools/fpc_tolerance.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/type_traits/common_type.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace assertion {
|
||||
namespace op {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** fpctraits ************** //
|
||||
// ************************************************************************** //
|
||||
// set of floating point comparison traits per comparison 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;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct fpctraits<op::LT<Lhs,Rhs> > {
|
||||
static const bool cmp_direct = false;
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs>
|
||||
struct fpctraits<op::GT<Lhs,Rhs> > {
|
||||
static const bool cmp_direct = false;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** 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)
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs, typename OP>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, OP* )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::NE<Lhs,Rhs>* )
|
||||
{
|
||||
fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_WEAK );
|
||||
|
||||
assertion_result ar( !P( lhs, rhs ) );
|
||||
if( !ar )
|
||||
ar.message() << "Relative difference is within tolerance ["
|
||||
<< P.tested_rel_diff() << " < " << fpc_tolerance<FPT>() << ']';
|
||||
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv_near_zero( FPT const& fpv, op::NE<Lhs,Rhs>* )
|
||||
{
|
||||
fpc::small_with_tolerance<FPT> P( fpc_tolerance<FPT>() );
|
||||
|
||||
assertion_result ar( !P( fpv ) );
|
||||
if( !ar )
|
||||
ar.message() << "Absolute value is within tolerance [|" << fpv << "| < "<< fpc_tolerance<FPT>() << ']';
|
||||
return ar;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::LT<Lhs,Rhs>* )
|
||||
{
|
||||
return lhs >= rhs ? assertion_result( false ) : compare_fpv<FPT>( lhs, rhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <typename FPT, typename Lhs, typename Rhs>
|
||||
inline assertion_result
|
||||
compare_fpv( Lhs const& lhs, Rhs const& rhs, op::GT<Lhs,Rhs>* )
|
||||
{
|
||||
return lhs <= rhs ? assertion_result( false ) : compare_fpv<FPT>( lhs, rhs, (op::NE<Lhs,Rhs>*)0 );
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define DEFINE_FPV_COMPARISON( oper, name, rev ) \
|
||||
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> { \
|
||||
public: \
|
||||
typedef typename common_type<Lhs,Rhs>::type FPT; \
|
||||
typedef name<Lhs,Rhs> OP; \
|
||||
\
|
||||
typedef assertion_result result_type; \
|
||||
\
|
||||
static bool \
|
||||
eval_direct( Lhs const& lhs, Rhs const& rhs ) \
|
||||
{ \
|
||||
return lhs oper rhs; \
|
||||
} \
|
||||
\
|
||||
static assertion_result \
|
||||
eval( Lhs const& lhs, Rhs const& rhs ) \
|
||||
{ \
|
||||
if( lhs == 0 ) \
|
||||
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 compare_fpv<FPT>( lhs, rhs, (OP*)0 ); \
|
||||
} \
|
||||
\
|
||||
template<typename PrevExprType> \
|
||||
static void \
|
||||
report( std::ostream& ostr, \
|
||||
PrevExprType const& lhs, \
|
||||
Rhs const& rhs ) \
|
||||
{ \
|
||||
lhs.report( ostr ); \
|
||||
ostr << revert() \
|
||||
<< tt_detail::print_helper( rhs ); \
|
||||
} \
|
||||
\
|
||||
static char const* revert() \
|
||||
{ return " " #rev " "; } \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_FPV_COMPARISON )
|
||||
#undef DEFINE_FPV_COMPARISON
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace op
|
||||
} // namespace assertion
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_FPC_OP_HPP_050915GER
|
||||
|
||||
103
thirdparty/source/boost_1_61_0/boost/test/tools/fpc_tolerance.hpp
vendored
Normal file
103
thirdparty/source/boost_1_61_0/boost/test/tools/fpc_tolerance.hpp
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : FPC tools tolerance holder
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
|
||||
#define BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
|
||||
|
||||
// Boost Test
|
||||
#include <boost/test/tree/decorator.hpp>
|
||||
#include <boost/test/tools/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
namespace fpc = math::fpc;
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** floating point comparison tolerance ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename FPT>
|
||||
inline FPT&
|
||||
fpc_tolerance()
|
||||
{
|
||||
static FPT s_value = 0;
|
||||
return s_value;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
struct local_fpc_tolerance {
|
||||
local_fpc_tolerance( FPT fraction_tolerance ) : m_old_tolerance( fpc_tolerance<FPT>() )
|
||||
{
|
||||
fpc_tolerance<FPT>() = fraction_tolerance;
|
||||
}
|
||||
|
||||
~local_fpc_tolerance()
|
||||
{
|
||||
if( m_old_tolerance != (FPT)-1 )
|
||||
fpc_tolerance<FPT>() = m_old_tolerance;
|
||||
}
|
||||
|
||||
private:
|
||||
// Data members
|
||||
FPT m_old_tolerance;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace test_tools
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::tolerance ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace unit_test {
|
||||
namespace decorator {
|
||||
|
||||
template<typename FPT>
|
||||
inline fixture_t
|
||||
tolerance( FPT v )
|
||||
{
|
||||
return fixture_t( test_unit_fixture_ptr(
|
||||
new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( v ) ) );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline fixture_t
|
||||
tolerance( test_tools::fpc::percent_tolerance_t<FPT> v )
|
||||
{
|
||||
return fixture_t( test_unit_fixture_ptr(
|
||||
new unit_test::class_based_fixture<test_tools::local_fpc_tolerance<FPT>,FPT>( boost::math::fpc::fpc_detail::fraction_tolerance<FPT>( v ) ) ) );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace decorator
|
||||
|
||||
using decorator::tolerance;
|
||||
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_FPC_TOLERANCE_HPP_121612GER
|
||||
369
thirdparty/source/boost_1_61_0/boost/test/tools/interface.hpp
vendored
Normal file
369
thirdparty/source/boost_1_61_0/boost/test/tools/interface.hpp
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 81247 $
|
||||
//
|
||||
// Description : contains definition for all test tools in test toolbox
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER
|
||||
#define BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#ifdef BOOST_TEST_TOOLS_DEBUGGABLE
|
||||
#include <boost/test/debug.hpp>
|
||||
#endif
|
||||
#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
|
||||
#include <boost/test/tools/detail/expression_holder.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/pp_variadic.hpp>
|
||||
|
||||
#ifdef BOOST_TEST_NO_OLD_TOOLS
|
||||
#include <boost/preprocessor/seq/to_tuple.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#endif // BOOST_TEST_NO_OLD_TOOLS
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_<level> ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_BUILD_ASSERTION( P ) \
|
||||
(::boost::test_tools::assertion::seed()->*P) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// Implementation based on direct predicate evaluation
|
||||
#define BOOST_TEST_TOOL_DIRECT_IMPL( P, level, M ) \
|
||||
do { \
|
||||
::boost::test_tools::assertion_result res = (P); \
|
||||
report_assertion( \
|
||||
res, \
|
||||
BOOST_TEST_LAZY_MSG( M ), \
|
||||
BOOST_TEST_L(__FILE__), \
|
||||
static_cast<std::size_t>(__LINE__), \
|
||||
::boost::test_tools::tt_detail::level, \
|
||||
::boost::test_tools::tt_detail::CHECK_MSG, \
|
||||
0 ); \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// Implementation based on expression template construction
|
||||
#define BOOST_TEST_TOOL_ET_IMPL( P, level ) \
|
||||
do { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
\
|
||||
::boost::test_tools::tt_detail:: \
|
||||
report_assertion( \
|
||||
BOOST_TEST_BUILD_ASSERTION( P ).evaluate(), \
|
||||
BOOST_TEST_LAZY_MSG( BOOST_TEST_STRINGIZE( P ) ), \
|
||||
BOOST_TEST_L(__FILE__), \
|
||||
static_cast<std::size_t>(__LINE__), \
|
||||
::boost::test_tools::tt_detail::level, \
|
||||
::boost::test_tools::tt_detail::CHECK_BUILT_ASSERTION, \
|
||||
0 ); \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// Implementation based on expression template construction with extra tool arguments
|
||||
#define BOOST_TEST_TOOL_ET_IMPL_EX( P, level, arg ) \
|
||||
do { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
\
|
||||
::boost::test_tools::tt_detail:: \
|
||||
report_assertion( \
|
||||
::boost::test_tools::tt_detail::assertion_evaluate( \
|
||||
BOOST_TEST_BUILD_ASSERTION( P ) ) \
|
||||
<< arg, \
|
||||
::boost::test_tools::tt_detail::assertion_text( \
|
||||
BOOST_TEST_LAZY_MSG( BOOST_TEST_STRINGIZE(P) ), \
|
||||
BOOST_TEST_LAZY_MSG( arg ) ), \
|
||||
BOOST_TEST_L(__FILE__), \
|
||||
static_cast<std::size_t>(__LINE__), \
|
||||
::boost::test_tools::tt_detail::level, \
|
||||
::boost::test_tools::tt_detail::assertion_type() \
|
||||
<< arg, \
|
||||
0 ); \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifdef BOOST_TEST_TOOLS_UNDER_DEBUGGER
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV( level, P ) \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
|
||||
BOOST_TEST_TOOL_UNIV( level, P ) \
|
||||
/**/
|
||||
|
||||
#elif defined(BOOST_TEST_TOOLS_DEBUGGABLE)
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV( level, P ) \
|
||||
do { \
|
||||
if( ::boost::debug::under_debugger() ) \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ); \
|
||||
else \
|
||||
BOOST_TEST_TOOL_ET_IMPL( P, level ); \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
|
||||
BOOST_TEST_TOOL_UNIV( level, P ) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV( level, P ) \
|
||||
BOOST_TEST_TOOL_ET_IMPL( P, level ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST_TOOL_UNIV_EX( level, P, ... ) \
|
||||
BOOST_TEST_TOOL_ET_IMPL_EX( P, level, __VA_ARGS__ ) \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_WARN( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
|
||||
2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, WARN, __VA_ARGS__ ) \
|
||||
/**/
|
||||
#define BOOST_TEST_CHECK( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
|
||||
2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, CHECK, __VA_ARGS__ ) \
|
||||
/**/
|
||||
#define BOOST_TEST_REQUIRE( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
|
||||
2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, REQUIRE, __VA_ARGS__ )\
|
||||
/**/
|
||||
|
||||
#define BOOST_TEST( ... ) BOOST_TEST_INVOKE_IF_N_ARGS( \
|
||||
2, BOOST_TEST_TOOL_UNIV, BOOST_TEST_TOOL_UNIV_EX, CHECK, __VA_ARGS__ ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M )
|
||||
#define BOOST_TEST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( symb, BOOST_STRINGIZE(= symb) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifdef BOOST_TEST_NO_OLD_TOOLS
|
||||
|
||||
#ifdef BOOST_TEST_TOOLS_UNDER_DEBUGGER
|
||||
|
||||
#define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
|
||||
do { try { \
|
||||
S; \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
|
||||
} catch( E ) { \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
|
||||
}} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
#elif defined(BOOST_TEST_TOOLS_DEBUGGABLE)
|
||||
|
||||
#define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
|
||||
do { try { \
|
||||
if( ::boost::debug::under_debugger() ) \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
S; \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
|
||||
} catch( E ) { \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
|
||||
}} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_CHECK_THROW_IMPL(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)\
|
||||
do { try { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
S; \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed ); \
|
||||
} catch( E ) { \
|
||||
BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught ); \
|
||||
}} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_THROW( S, E ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const&, WARN, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
#define BOOST_CHECK_THROW( S, E ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const&, CHECK, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
#define BOOST_REQUIRE_THROW( S, E ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const&, REQUIRE, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
true , "exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EXCEPTION( S, E, P ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const& ex, WARN, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
#define BOOST_CHECK_EXCEPTION( S, E, P ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const& ex, CHECK, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
#define BOOST_REQUIRE_EXCEPTION( S, E, P ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, E const& ex, REQUIRE, \
|
||||
false, "exception " BOOST_STRINGIZE(E) " is expected", \
|
||||
P(ex), "incorrect exception " BOOST_STRINGIZE(E) " is caught" ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_NO_THROW( S ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, ..., WARN, \
|
||||
true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
|
||||
false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
|
||||
/**/
|
||||
#define BOOST_CHECK_NO_THROW( S ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, ..., CHECK, \
|
||||
true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
|
||||
false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
|
||||
/**/
|
||||
#define BOOST_REQUIRE_NO_THROW( S ) \
|
||||
BOOST_CHECK_THROW_IMPL(S, ..., REQUIRE, \
|
||||
true , "no exceptions thrown by " BOOST_STRINGIZE( S ), \
|
||||
false, "exception thrown by " BOOST_STRINGIZE( S ) ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, WARN, M )
|
||||
#define BOOST_CHECK_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, CHECK, M )
|
||||
#define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_TEST_TOOL_DIRECT_IMPL( P, REQUIRE, M )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// DEPRECATED TOOLS /////////////////////////////
|
||||
|
||||
#define BOOST_WARN( P ) BOOST_TEST_WARN( P )
|
||||
#define BOOST_CHECK( P ) BOOST_TEST_CHECK( P )
|
||||
#define BOOST_REQUIRE( P ) BOOST_TEST_REQUIRE( P )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_ERROR( M ) BOOST_TEST_ERROR( M )
|
||||
#define BOOST_FAIL( M ) BOOST_TEST_FAIL( M )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EQUAL( L, R ) BOOST_TEST_WARN( L == R )
|
||||
#define BOOST_CHECK_EQUAL( L, R ) BOOST_TEST_CHECK( L == R )
|
||||
#define BOOST_REQUIRE_EQUAL( L, R ) BOOST_TEST_REQUIRE( L == R )
|
||||
|
||||
#define BOOST_WARN_NE( L, R ) BOOST_TEST_WARN( L != R )
|
||||
#define BOOST_CHECK_NE( L, R ) BOOST_TEST_CHECK( L != R )
|
||||
#define BOOST_REQUIRE_NE( L, R ) BOOST_TEST_REQUIRE( L != R )
|
||||
|
||||
#define BOOST_WARN_LT( L, R ) BOOST_TEST_WARN( L < R )
|
||||
#define BOOST_CHECK_LT( L, R ) BOOST_TEST_CHECK( L < R )
|
||||
#define BOOST_REQUIRE_LT( L, R ) BOOST_TEST_REQUIRE( L < R )
|
||||
|
||||
#define BOOST_WARN_LE( L, R ) BOOST_TEST_WARN( L <= R )
|
||||
#define BOOST_CHECK_LE( L, R ) BOOST_TEST_CHECK( L <= R )
|
||||
#define BOOST_REQUIRE_LE( L, R ) BOOST_TEST_REQUIRE( L <= R )
|
||||
|
||||
#define BOOST_WARN_GT( L, R ) BOOST_TEST_WARN( L > R )
|
||||
#define BOOST_CHECK_GT( L, R ) BOOST_TEST_CHECK( L > R )
|
||||
#define BOOST_REQUIRE_GT( L, R ) BOOST_TEST_REQUIRE( L > R )
|
||||
|
||||
#define BOOST_WARN_GE( L, R ) BOOST_TEST_WARN( L >= R )
|
||||
#define BOOST_CHECK_GE( L, R ) BOOST_TEST_CHECK( L >= R )
|
||||
#define BOOST_REQUIRE_GE( L, R ) BOOST_TEST_REQUIRE( L >= R )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_CLOSE( L, R, T ) BOOST_TEST_WARN( L == R, T % ::boost::test_tools::tolerance() )
|
||||
#define BOOST_CHECK_CLOSE( L, R, T ) BOOST_TEST_CHECK( L == R, T % ::boost::test_tools::tolerance() )
|
||||
#define BOOST_REQUIRE_CLOSE( L, R, T ) BOOST_TEST_REQUIRE( L == R, T % ::boost::test_tools::tolerance() )
|
||||
|
||||
#define BOOST_WARN_CLOSE_FRACTION(L, R, T) BOOST_TEST_WARN( L == R, ::boost::test_tools::tolerance( T ) )
|
||||
#define BOOST_CHECK_CLOSE_FRACTION(L, R, T) BOOST_TEST_CHECK( L == R, ::boost::test_tools::tolerance( T ) )
|
||||
#define BOOST_REQUIRE_CLOSE_FRACTION(L,R,T) BOOST_TEST_REQUIRE( L == R, ::boost::test_tools::tolerance( T ) )
|
||||
|
||||
#define BOOST_WARN_SMALL( FPV, T ) BOOST_TEST_WARN( FPV == 0., ::boost::test_tools::tolerance( T ) )
|
||||
#define BOOST_CHECK_SMALL( FPV, T ) BOOST_TEST_CHECK( FPV == 0., ::boost::test_tools::tolerance( T ) )
|
||||
#define BOOST_REQUIRE_SMALL( FPV, T ) BOOST_TEST_REQUIRE( FPV == 0., ::boost::test_tools::tolerance( T ) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_WARN( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
|
||||
::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
|
||||
::boost::test_tools::per_element() ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_CHECK( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
|
||||
::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
|
||||
::boost::test_tools::per_element() ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_REQUIRE( ::boost::test_tools::tt_detail::make_it_pair(L_begin, L_end) ==\
|
||||
::boost::test_tools::tt_detail::make_it_pair(R_begin, R_end), \
|
||||
::boost::test_tools::per_element() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_BITWISE_EQUAL( L, R ) BOOST_TEST_WARN( L == R, ::boost::test_tools::bitwise() )
|
||||
#define BOOST_CHECK_BITWISE_EQUAL( L, R ) BOOST_TEST_CHECK( L == R, ::boost::test_tools::bitwise() )
|
||||
#define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_TEST_REQUIRE( L == R, ::boost::test_tools::bitwise() )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_PREDICATE( P, ARGS ) BOOST_TEST_WARN( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
|
||||
#define BOOST_CHECK_PREDICATE( P, ARGS ) BOOST_TEST_CHECK( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
|
||||
#define BOOST_REQUIRE_PREDICATE( P, ARGS ) BOOST_TEST_REQUIRE( P BOOST_PP_SEQ_TO_TUPLE(ARGS) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#endif // BOOST_TEST_NO_OLD_TOOLS
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_INTERFACE_HPP_111712GER
|
||||
358
thirdparty/source/boost_1_61_0/boost/test/tools/old/impl.hpp
vendored
Normal file
358
thirdparty/source/boost_1_61_0/boost/test/tools/old/impl.hpp
vendored
Normal file
@@ -0,0 +1,358 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : implementation details for old toolbox
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_OLD_IMPL_HPP_012705GER
|
||||
#define BOOST_TEST_TOOLS_OLD_IMPL_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
#include <boost/test/tools/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/test/tools/detail/fwd.hpp>
|
||||
#include <boost/test/tools/detail/print_helper.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/numeric/conversion/conversion_traits.hpp> // for numeric::conversion_traits
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/add.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** old TOOLBOX Implementation ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
// This function adds level of indirection, but it makes sure we evaluate predicate
|
||||
// arguments only once
|
||||
|
||||
#ifndef BOOST_TEST_PROD
|
||||
#define TEMPL_PARAMS( z, m, dummy ) , typename BOOST_JOIN( Arg, m )
|
||||
|
||||
#define FUNC_PARAMS( z, m, dummy ) \
|
||||
, BOOST_JOIN( Arg, m ) const& BOOST_JOIN( arg, m ) \
|
||||
, char const* BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \
|
||||
/**/
|
||||
|
||||
#define PRED_PARAMS( z, m, dummy ) BOOST_PP_COMMA_IF( m ) BOOST_JOIN( arg, m )
|
||||
|
||||
#define ARG_INFO( z, m, dummy ) \
|
||||
, BOOST_JOIN( BOOST_JOIN( arg, m ), _descr ) \
|
||||
, &static_cast<const unit_test::lazy_ostream&>(unit_test::lazy_ostream::instance() \
|
||||
<< ::boost::test_tools::tt_detail::print_helper( BOOST_JOIN( arg, m ) )) \
|
||||
/**/
|
||||
|
||||
#define IMPL_FRWD( z, n, dummy ) \
|
||||
template<typename Pred \
|
||||
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), TEMPL_PARAMS, _ )> \
|
||||
inline bool \
|
||||
check_frwd( Pred P, unit_test::lazy_ostream const& assertion_descr, \
|
||||
const_string file_name, std::size_t line_num, \
|
||||
tool_level tl, check_type ct \
|
||||
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), FUNC_PARAMS, _ ) \
|
||||
) \
|
||||
{ \
|
||||
return \
|
||||
report_assertion( P( BOOST_PP_REPEAT_ ## z(BOOST_PP_ADD(n, 1), PRED_PARAMS,_) ),\
|
||||
assertion_descr, file_name, line_num, tl, ct, \
|
||||
BOOST_PP_ADD( n, 1 ) \
|
||||
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) \
|
||||
); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#ifndef BOOST_TEST_MAX_PREDICATE_ARITY
|
||||
#define BOOST_TEST_MAX_PREDICATE_ARITY 5
|
||||
#endif
|
||||
|
||||
BOOST_PP_REPEAT( BOOST_TEST_MAX_PREDICATE_ARITY, IMPL_FRWD, _ )
|
||||
|
||||
#undef TEMPL_PARAMS
|
||||
#undef FUNC_PARAMS
|
||||
#undef PRED_INFO
|
||||
#undef ARG_INFO
|
||||
#undef IMPL_FRWD
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template <class Left, class Right>
|
||||
inline assertion_result equal_impl( Left const& left, Right const& right )
|
||||
{
|
||||
return left == right;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
inline assertion_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
inline assertion_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
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 );
|
||||
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) ); }
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct equal_impl_frwd {
|
||||
template <typename Left, typename Right>
|
||||
inline assertion_result
|
||||
call_impl( Left const& left, Right const& right, mpl::false_ ) const
|
||||
{
|
||||
return equal_impl( left, right );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline assertion_result
|
||||
call_impl( Left const& left, Right const& right, mpl::true_ ) const
|
||||
{
|
||||
return (*this)( right, &left[0] );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline assertion_result
|
||||
operator()( Left const& left, Right const& right ) const
|
||||
{
|
||||
typedef typename is_array<Left>::type left_is_array;
|
||||
return call_impl( left, right, left_is_array() );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct ne_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return !equal_impl_frwd()( left, right );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct lt_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left < right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct le_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left <= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct gt_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left > right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct ge_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left >= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct equal_coll_impl {
|
||||
template <typename Left, typename Right>
|
||||
assertion_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end )
|
||||
{
|
||||
assertion_result pr( true );
|
||||
std::size_t pos = 0;
|
||||
|
||||
for( ; left_begin != left_end && right_begin != right_end; ++left_begin, ++right_begin, ++pos ) {
|
||||
if( *left_begin != *right_begin ) {
|
||||
pr = false;
|
||||
pr.message() << "\nMismatch at position " << pos << ": "
|
||||
<< ::boost::test_tools::tt_detail::print_helper(*left_begin)
|
||||
<< " != "
|
||||
<< ::boost::test_tools::tt_detail::print_helper(*right_begin);
|
||||
}
|
||||
}
|
||||
|
||||
if( left_begin != left_end ) {
|
||||
std::size_t r_size = pos;
|
||||
while( left_begin != left_end ) {
|
||||
++pos;
|
||||
++left_begin;
|
||||
}
|
||||
|
||||
pr = false;
|
||||
pr.message() << "\nCollections size mismatch: " << pos << " != " << r_size;
|
||||
}
|
||||
|
||||
if( right_begin != right_end ) {
|
||||
std::size_t l_size = pos;
|
||||
while( right_begin != right_end ) {
|
||||
++pos;
|
||||
++right_begin;
|
||||
}
|
||||
|
||||
pr = false;
|
||||
pr.message() << "\nCollections size mismatch: " << l_size << " != " << pos;
|
||||
}
|
||||
|
||||
return pr;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct bitwise_equal_impl {
|
||||
template <class Left, class Right>
|
||||
assertion_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
assertion_result pr( true );
|
||||
|
||||
std::size_t left_bit_size = sizeof(Left)*CHAR_BIT;
|
||||
std::size_t right_bit_size = sizeof(Right)*CHAR_BIT;
|
||||
|
||||
static Left const leftOne( 1 );
|
||||
static Right const rightOne( 1 );
|
||||
|
||||
std::size_t total_bits = left_bit_size < right_bit_size ? left_bit_size : right_bit_size;
|
||||
|
||||
for( std::size_t counter = 0; counter < total_bits; ++counter ) {
|
||||
if( ( left & ( leftOne << counter ) ) != ( right & ( rightOne << counter ) ) ) {
|
||||
pr = false;
|
||||
pr.message() << "\nMismatch at position " << counter;
|
||||
}
|
||||
}
|
||||
|
||||
if( left_bit_size != right_bit_size ) {
|
||||
pr = false;
|
||||
pr.message() << "\nOperands bit sizes mismatch: " << left_bit_size << " != " << right_bit_size;
|
||||
}
|
||||
|
||||
return pr;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT1, typename FPT2>
|
||||
struct comp_supertype {
|
||||
// deduce "better" type from types of arguments being compared
|
||||
// if one type is floating and the second integral we use floating type and
|
||||
// value of integral type is promoted to the floating. The same for float and double
|
||||
// But we don't want to compare two values of integral types using this tool.
|
||||
typedef typename numeric::conversion_traits<FPT1,FPT2>::supertype type;
|
||||
BOOST_STATIC_ASSERT_MSG( !is_integral<type>::value, "Only floating-point types can be compared!");
|
||||
};
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
namespace fpc = math::fpc;
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** check_is_close ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct BOOST_TEST_DECL check_is_close_t {
|
||||
// Public typedefs
|
||||
typedef assertion_result result_type;
|
||||
|
||||
template<typename FPT1, typename FPT2, typename ToleranceType>
|
||||
assertion_result
|
||||
operator()( FPT1 left, FPT2 right, ToleranceType tolerance ) const
|
||||
{
|
||||
fpc::close_at_tolerance<typename tt_detail::comp_supertype<FPT1,FPT2>::type> pred( tolerance, fpc::FPC_STRONG );
|
||||
|
||||
assertion_result ar( pred( left, right ) );
|
||||
|
||||
if( !ar )
|
||||
ar.message() << pred.tested_rel_diff();
|
||||
|
||||
return ar;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT1, typename FPT2, typename ToleranceType>
|
||||
inline assertion_result
|
||||
check_is_close( FPT1 left, FPT2 right, ToleranceType tolerance )
|
||||
{
|
||||
return check_is_close_t()( left, right, tolerance );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** check_is_small ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct BOOST_TEST_DECL check_is_small_t {
|
||||
// Public typedefs
|
||||
typedef bool result_type;
|
||||
|
||||
template<typename FPT>
|
||||
bool
|
||||
operator()( FPT fpv, FPT tolerance ) const
|
||||
{
|
||||
return fpc::is_small( fpv, tolerance );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename FPT>
|
||||
inline bool
|
||||
check_is_small( FPT fpv, FPT tolerance )
|
||||
{
|
||||
return fpc::is_small( fpv, tolerance );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_OLD_IMPL_HPP_012705GER
|
||||
282
thirdparty/source/boost_1_61_0/boost/test/tools/old/interface.hpp
vendored
Normal file
282
thirdparty/source/boost_1_61_0/boost/test/tools/old/interface.hpp
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 81247 $
|
||||
//
|
||||
// Description : contains definition for all test tools in old test toolbox
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER
|
||||
#define BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER
|
||||
|
||||
// Boost
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <boost/preprocessor/seq/to_tuple.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** TOOL BOX ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
// In macros below following argument abbreviations are used:
|
||||
// P - predicate
|
||||
// M - message
|
||||
// S - statement
|
||||
// E - exception
|
||||
// L - left argument
|
||||
// R - right argument
|
||||
// TL - tool level
|
||||
// CT - check type
|
||||
// ARGS - arguments list (as PP sequence)
|
||||
|
||||
// frwd_type:
|
||||
// 0 - args exists and need to be forwarded; call check_frwd
|
||||
// 1 - args exists, but do not need to be forwarded; call report_assertion directly
|
||||
// 2 - no arguments; call report_assertion directly
|
||||
|
||||
#define BOOST_TEST_TOOL_PASS_PRED0( P, ARGS ) P
|
||||
#define BOOST_TEST_TOOL_PASS_PRED1( P, ARGS ) P BOOST_PP_SEQ_TO_TUPLE(ARGS)
|
||||
#define BOOST_TEST_TOOL_PASS_PRED2( P, ARGS ) P
|
||||
|
||||
#define BOOST_TEST_TOOL_PASS_ARG( r, _, arg ) , arg, BOOST_STRINGIZE( arg )
|
||||
#define BOOST_TEST_TOOL_PASS_ARG_DSCR( r, _, arg ) , BOOST_STRINGIZE( arg )
|
||||
|
||||
#define BOOST_TEST_TOOL_PASS_ARGS0( ARGS ) \
|
||||
BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_TOOL_PASS_ARG, _, ARGS )
|
||||
#define BOOST_TEST_TOOL_PASS_ARGS1( ARGS ) \
|
||||
, BOOST_PP_SEQ_SIZE(ARGS) BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_TOOL_PASS_ARG_DSCR, _, ARGS )
|
||||
#define BOOST_TEST_TOOL_PASS_ARGS2( ARGS ) \
|
||||
, 0
|
||||
|
||||
#define BOOST_TEST_TOOL_IMPL( frwd_type, P, assertion_descr, TL, CT, ARGS ) \
|
||||
do { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
::boost::test_tools::tt_detail:: \
|
||||
BOOST_PP_IF( frwd_type, report_assertion, check_frwd ) ( \
|
||||
BOOST_JOIN( BOOST_TEST_TOOL_PASS_PRED, frwd_type )( P, ARGS ), \
|
||||
BOOST_TEST_LAZY_MSG( assertion_descr ), \
|
||||
BOOST_TEST_L(__FILE__), \
|
||||
static_cast<std::size_t>(__LINE__), \
|
||||
::boost::test_tools::tt_detail::TL, \
|
||||
::boost::test_tools::tt_detail::CT \
|
||||
BOOST_JOIN( BOOST_TEST_TOOL_PASS_ARGS, frwd_type )( ARGS ) ); \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN( P ) BOOST_TEST_TOOL_IMPL( 2, \
|
||||
(P), BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED, _ )
|
||||
#define BOOST_CHECK( P ) BOOST_TEST_TOOL_IMPL( 2, \
|
||||
(P), BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED, _ )
|
||||
#define BOOST_REQUIRE( P ) BOOST_TEST_TOOL_IMPL( 2, \
|
||||
(P), BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED, _ )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, WARN, CHECK_MSG, _ )
|
||||
#define BOOST_CHECK_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, CHECK, CHECK_MSG, _ )
|
||||
#define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, REQUIRE, CHECK_MSG, _ )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M )
|
||||
#define BOOST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL ) \
|
||||
do { \
|
||||
try { \
|
||||
BOOST_TEST_PASSPOINT(); \
|
||||
S; \
|
||||
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, \
|
||||
TL, CHECK_MSG, _ ); \
|
||||
} \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "", WARN )
|
||||
#define BOOST_CHECK_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "", CHECK )
|
||||
#define BOOST_REQUIRE_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "", REQUIRE )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
|
||||
": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", WARN )
|
||||
#define BOOST_CHECK_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
|
||||
": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", CHECK )
|
||||
#define BOOST_REQUIRE_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), \
|
||||
": validation on the raised exception through predicate \"" BOOST_STRINGIZE(P) "\"", REQUIRE )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_CHECK_NO_THROW_IMPL( S, TL ) \
|
||||
do { \
|
||||
try { \
|
||||
S; \
|
||||
BOOST_TEST_TOOL_IMPL( 2, true, "no exceptions thrown by " BOOST_STRINGIZE( S ), \
|
||||
TL, CHECK_MSG, _ ); \
|
||||
} catch( ... ) { \
|
||||
BOOST_TEST_TOOL_IMPL( 2, false, "unexpected exception thrown by " BOOST_STRINGIZE( S ), \
|
||||
TL, CHECK_MSG, _ ); \
|
||||
} \
|
||||
} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
|
||||
/**/
|
||||
|
||||
#define BOOST_WARN_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, WARN )
|
||||
#define BOOST_CHECK_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, CHECK )
|
||||
#define BOOST_REQUIRE_NO_THROW( S ) BOOST_CHECK_NO_THROW_IMPL( S, REQUIRE )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::equal_impl_frwd(), "", WARN, CHECK_EQUAL, (L)(R) )
|
||||
#define BOOST_CHECK_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::equal_impl_frwd(), "", CHECK, CHECK_EQUAL, (L)(R) )
|
||||
#define BOOST_REQUIRE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::equal_impl_frwd(), "", REQUIRE, CHECK_EQUAL, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R) )
|
||||
#define BOOST_CHECK_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R) )
|
||||
#define BOOST_REQUIRE_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R) )
|
||||
#define BOOST_CHECK_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R) )
|
||||
#define BOOST_REQUIRE_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R) )
|
||||
#define BOOST_CHECK_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R) )
|
||||
#define BOOST_REQUIRE_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R) )
|
||||
#define BOOST_CHECK_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R) )
|
||||
#define BOOST_REQUIRE_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R) )
|
||||
#define BOOST_CHECK_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R) )
|
||||
#define BOOST_REQUIRE_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", WARN, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
|
||||
#define BOOST_CHECK_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", CHECK, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
|
||||
#define BOOST_REQUIRE_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", REQUIRE, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_CLOSE_FRACTION(L, R, T) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", WARN, CHECK_CLOSE_FRACTION, (L)(R)(T) )
|
||||
#define BOOST_CHECK_CLOSE_FRACTION(L, R, T) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", CHECK, CHECK_CLOSE_FRACTION, (L)(R)(T) )
|
||||
#define BOOST_REQUIRE_CLOSE_FRACTION(L,R,T) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_close_t(), "", REQUIRE, CHECK_CLOSE_FRACTION, (L)(R)(T) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_small_t(), "", WARN, CHECK_SMALL, (FPV)(T) )
|
||||
#define BOOST_CHECK_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_small_t(), "", CHECK, CHECK_SMALL, (FPV)(T) )
|
||||
#define BOOST_REQUIRE_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
::boost::test_tools::check_is_small_t(), "", REQUIRE, CHECK_SMALL, (FPV)(T) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
P, BOOST_TEST_STRINGIZE( P ), WARN, CHECK_PRED_WITH_ARGS, ARGS )
|
||||
#define BOOST_CHECK_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
P, BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED_WITH_ARGS, ARGS )
|
||||
#define BOOST_REQUIRE_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
|
||||
P, BOOST_TEST_STRINGIZE( P ), REQUIRE, CHECK_PRED_WITH_ARGS, ARGS )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(), \
|
||||
"", WARN, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) ) \
|
||||
/**/
|
||||
#define BOOST_CHECK_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(), \
|
||||
"", CHECK, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) ) \
|
||||
/**/
|
||||
#define BOOST_REQUIRE_EQUAL_COLLECTIONS( L_begin, L_end, R_begin, R_end ) \
|
||||
BOOST_TEST_TOOL_IMPL( 1, ::boost::test_tools::tt_detail::equal_coll_impl(), \
|
||||
"", REQUIRE, CHECK_EQUAL_COLL, (L_begin)(L_end)(R_begin)(R_end) ) \
|
||||
/**/
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_WARN_BITWISE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 1, \
|
||||
::boost::test_tools::tt_detail::bitwise_equal_impl(), "", WARN, CHECK_BITWISE_EQUAL, (L)(R) )
|
||||
#define BOOST_CHECK_BITWISE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 1, \
|
||||
::boost::test_tools::tt_detail::bitwise_equal_impl(), "", CHECK, CHECK_BITWISE_EQUAL, (L)(R) )
|
||||
#define BOOST_REQUIRE_BITWISE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 1, \
|
||||
::boost::test_tools::tt_detail::bitwise_equal_impl(), "", REQUIRE, CHECK_BITWISE_EQUAL, (L)(R) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifdef BOOST_TEST_NO_NEW_TOOLS
|
||||
|
||||
#define BOOST_TEST_WARN( P ) BOOST_WARN( P )
|
||||
#define BOOST_TEST_CHECK( P ) BOOST_CHECK( P )
|
||||
#define BOOST_TEST_REQUIRE( P ) BOOST_REQUIRE( P )
|
||||
|
||||
#define BOOST_TEST( P ) BOOST_CHECK( P )
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TOOLS_OLD_INTERFACE_HPP_111712GER
|
||||
96
thirdparty/source/boost_1_61_0/boost/test/tools/output_test_stream.hpp
vendored
Normal file
96
thirdparty/source/boost_1_61_0/boost/test/tools/output_test_stream.hpp
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
/// @file
|
||||
/// @brief output_test_stream class definition
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
|
||||
#define BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/tools/assertion_result.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** output_test_stream ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace test_tools {
|
||||
|
||||
//! Class to be used to simplify testing of ostream-based output operations
|
||||
class BOOST_TEST_DECL output_test_stream : public wrap_stringstream::wrapped_stream {
|
||||
typedef unit_test::const_string const_string;
|
||||
public:
|
||||
//! Constructor
|
||||
//!
|
||||
//!@param[in] pattern_file_name indicates the name of the file for matching. If the
|
||||
//! string is empty, the standard input or output streams are used instead
|
||||
//! (depending on match_or_save)
|
||||
//!@param[in] match_or_save if true, the pattern file will be read, otherwise it will be
|
||||
//! written
|
||||
//!@param[in] text_or_binary if false, opens the stream in binary mode. Otherwise the stream
|
||||
//! is opened with default flags and the carriage returns are ignored.
|
||||
explicit output_test_stream( const_string pattern_file_name = const_string(),
|
||||
bool match_or_save = true,
|
||||
bool text_or_binary = true );
|
||||
|
||||
// Destructor
|
||||
~output_test_stream();
|
||||
|
||||
//! Checks if the stream is empty
|
||||
//!
|
||||
//!@param[in] flush_stream if true, flushes the stream after the call
|
||||
assertion_result is_empty( bool flush_stream = true );
|
||||
|
||||
//! Checks the length of the stream
|
||||
//!
|
||||
//!@param[in] length target length
|
||||
//!@param[in] flush_stream if true, flushes the stream after the call. Set to false to call
|
||||
//! additional checks on the same content.
|
||||
assertion_result check_length( std::size_t length, bool flush_stream = true );
|
||||
|
||||
//! Checks the content of the stream against a string
|
||||
//!
|
||||
//!@param[in] arg_ the target stream
|
||||
//!@param[in] flush_stream if true, flushes the stream after the call.
|
||||
assertion_result is_equal( const_string arg_, bool flush_stream = true );
|
||||
|
||||
//! Checks the content of the stream against a pattern file
|
||||
//!
|
||||
//!@param[in] flush_stream if true, flushes the stream after the call.
|
||||
assertion_result match_pattern( bool flush_stream = true );
|
||||
|
||||
//! Flushes the stream
|
||||
void flush();
|
||||
|
||||
private:
|
||||
// helper functions
|
||||
std::size_t length();
|
||||
void sync();
|
||||
|
||||
struct Impl;
|
||||
Impl* m_pimpl;
|
||||
};
|
||||
|
||||
} // namespace test_tools
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_OUTPUT_TEST_STREAM_HPP_012705GER
|
||||
Reference in New Issue
Block a user