|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82718 - in trunk/boost/test: . data/monomorphic/generators detail impl tools tools/detail tools/old tree utils utils/basic_cstring utils/runtime/cla utils/runtime/env utils/runtime/file
From: gennadiy.rozental_at_[hidden]
Date: 2013-02-06 20:25:21
Author: rogeeff
Date: 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
New Revision: 82718
URL: http://svn.boost.org/trac/boost/changeset/82718
Log:
Preparing for supporting both new and old testing tools implementation, including macros to manage which one is to be used. Start using new tools internally. Completely split new and old tools implementation so they do not interfere with each other and also can be stitched on/off by macro separately.
Added support for collection comparison interface using BOOST_CHECK( c1 == c2 ). This interface supports all forward iterable collections (including boost::range, but it is currently broken due to error in boost::range.
Added support for floating point comparisons using BOOST_CHECK( a == b, tolerance ) interface. Both percent and fraction tolerance are supported.
NEW feature: added support for floating point comparisons using BOOST_CHECK( a >= b, tolerance ) interface (all kinds of comparisons: != >= >, <= <). Both percent and fraction tolerance are supported.
NEW feature: added support for bitwise comparison using BOOST_CHECK( a == b, bitwise ) interface
NEW feature: sticky tolerance. We now can specify type specific tolerance once and use it in multiple BOOST_CHECK( a==b ) with floating point values without specifying one. More over one can now specify a tolerance for the test case using the new decorator decorator::tolerance()
NEW feature: added support for fixture decorator with an argument
Rerouted printing values in new tools message formatting implementation through the print_helper_t interface to facilitate used defined overwrite.
predicate_result-> assertion_result to better convey the intended use
Implemented new error message formatting helpers
check_is_close_t, check_is_small_t eliminated. Use either functions or new tools API instead.
Added full set of comparison routines for basic_cstring
New traits: is_cstring
is_forward_iterable implementation improved
Failure to open a pattern file is not a warning, but just a message now
Use new C++11 config macros
Added:
trunk/boost/test/tools/assertion_result.hpp
- copied, changed from r82045, /trunk/boost/test/tools/predicate_result.hpp
trunk/boost/test/tools/context.hpp (contents, props changed)
trunk/boost/test/tools/detail/
trunk/boost/test/tools/detail/bitwise_manip.hpp (contents, props changed)
trunk/boost/test/tools/detail/expression_holder.hpp (contents, props changed)
trunk/boost/test/tools/detail/fwd.hpp (contents, props changed)
trunk/boost/test/tools/detail/indirections.hpp (contents, props changed)
trunk/boost/test/tools/detail/it_pair.hpp (contents, props changed)
trunk/boost/test/tools/detail/print_helper.hpp (contents, props changed)
trunk/boost/test/tools/detail/tolerance_manip.hpp (contents, props changed)
trunk/boost/test/tools/fpc_tolerance.hpp (contents, props changed)
trunk/boost/test/tools/interface.hpp (contents, props changed)
trunk/boost/test/tools/old/
trunk/boost/test/tools/old/impl.hpp (contents, props changed)
trunk/boost/test/tools/old/interface.hpp (contents, props changed)
trunk/boost/test/utils/is_cstring.hpp (contents, props changed)
Removed:
trunk/boost/test/tools/impl.hpp
trunk/boost/test/tools/predicate_result.hpp
Text files modified:
trunk/boost/test/data/monomorphic/generators/random.hpp | 4
trunk/boost/test/detail/global_typedef.hpp | 2
trunk/boost/test/impl/exception_safety.ipp | 3
trunk/boost/test/impl/framework.ipp | 2
trunk/boost/test/impl/logged_expectations.ipp | 29 +-
trunk/boost/test/impl/test_main.ipp | 1
trunk/boost/test/impl/test_tools.ipp | 100 ++++++---
trunk/boost/test/impl/unit_test_monitor.ipp | 1
trunk/boost/test/predicate_result.hpp | 4
trunk/boost/test/test_tools.hpp | 376 ++-------------------------------------
trunk/boost/test/tools/assertion.hpp | 335 +++++++++++++++++++++++++++--------
trunk/boost/test/tools/assertion_result.hpp | 12
trunk/boost/test/tools/floating_point_comparison.hpp | 88 ++-------
trunk/boost/test/tools/output_test_stream.hpp | 10
trunk/boost/test/tools/prod_tools.hpp | 12
trunk/boost/test/tree/decorator.hpp | 9
trunk/boost/test/tree/fixture.hpp | 22 ++
trunk/boost/test/unit_test_log.hpp | 2
trunk/boost/test/utils/basic_cstring/compare.hpp | 34 +++
trunk/boost/test/utils/is_forward_iterable.hpp | 9
trunk/boost/test/utils/lazy_ostream.hpp | 2
trunk/boost/test/utils/runtime/cla/parameter.hpp | 2
trunk/boost/test/utils/runtime/env/variable.hpp | 2
trunk/boost/test/utils/runtime/file/config_file_iterator.hpp | 3
24 files changed, 482 insertions(+), 582 deletions(-)
Modified: trunk/boost/test/data/monomorphic/generators/random.hpp
==============================================================================
--- trunk/boost/test/data/monomorphic/generators/random.hpp (original)
+++ trunk/boost/test/data/monomorphic/generators/random.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -18,7 +18,7 @@
// Boost.Test
#include <boost/test/data/config.hpp>
-#ifndef BOOST_NO_CXX11_HDR_RANDOM
+#ifndef BOOST_NO_0X_HDR_RANDOM
#include <boost/test/data/monomorphic/generate.hpp>
#include <boost/test/data/monomorphic/generators/keywords.hpp>
@@ -158,7 +158,7 @@
#include <boost/test/detail/enable_warnings.hpp>
-#endif // BOOST_NO_CXX11_HDR_RANDOM
+#endif // BOOST_NO_0X_HDR_RANDOM
#endif // BOOST_TEST_DATA_MONOMORPHIC_GENERATORS_RANDOM_HPP_101512GER
Modified: trunk/boost/test/detail/global_typedef.hpp
==============================================================================
--- trunk/boost/test/detail/global_typedef.hpp (original)
+++ trunk/boost/test/detail/global_typedef.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -18,7 +18,7 @@
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
#include <boost/test/detail/workaround.hpp>
-#define BOOST_TEST_L( s ) boost::unit_test::const_string( s, sizeof( s ) - 1 )
+#define BOOST_TEST_L( s ) ::boost::unit_test::const_string( s, sizeof( s ) - 1 )
#define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) )
#define BOOST_TEST_EMPTY_STRING BOOST_TEST_L( "" )
Modified: trunk/boost/test/impl/exception_safety.ipp
==============================================================================
--- trunk/boost/test/impl/exception_safety.ipp (original)
+++ trunk/boost/test/impl/exception_safety.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -27,12 +27,13 @@
#include <boost/test/utils/iterator/token_iterator.hpp>
#include <boost/test/interaction/interaction_based.hpp>
-#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test_log.hpp>
#include <boost/test/framework.hpp>
#include <boost/test/tree/observer.hpp>
#include <boost/test/debug.hpp>
+#include <boost/test/test_tools.hpp> // BOOST_REQUIRE_MESSAGE
+
#include <boost/test/detail/suppress_warnings.hpp>
// Boost
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -24,7 +24,6 @@
#include <boost/test/results_collector.hpp>
#include <boost/test/progress_monitor.hpp>
#include <boost/test/results_reporter.hpp>
-#include <boost/test/test_tools.hpp>
#include <boost/test/tree/observer.hpp>
#include <boost/test/tree/test_unit.hpp>
@@ -40,6 +39,7 @@
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/utils/foreach.hpp>
+#include <boost/test/utils/basic_cstring/io.hpp>
// Boost
#include <boost/timer.hpp>
Modified: trunk/boost/test/impl/logged_expectations.ipp
==============================================================================
--- trunk/boost/test/impl/logged_expectations.ipp (original)
+++ trunk/boost/test/impl/logged_expectations.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -21,13 +21,13 @@
#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
#include <boost/test/detail/global_typedef.hpp>
+#include <boost/test/detail/suppress_warnings.hpp>
#include <boost/test/utils/iterator/token_iterator.hpp>
#include <boost/test/interaction/interaction_based.hpp>
-#include <boost/test/test_tools.hpp>
-#include <boost/test/detail/suppress_warnings.hpp>
+#include <boost/test/test_tools.hpp> // BOOST_REQUIRE_MESSAGE
// Boost
#include <boost/lexical_cast.hpp>
@@ -96,9 +96,9 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, FILE_SIG );
+ BOOST_CHECK( *tit == FILE_SIG );
++tit;
- BOOST_CHECK_EQUAL( *tit, ELOG_VER );
+ BOOST_CHECK( *tit == ELOG_VER );
}
else {
m_log_file << FILE_SIG << CLMN_SEP << ELOG_VER << LINE_SEP;
@@ -118,7 +118,8 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, DP_SIG ); ++tit;
+ BOOST_CHECK( *tit == DP_SIG );
+ ++tit;
return lexical_cast<bool>( *tit );
}
else {
@@ -141,8 +142,9 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, SCOPE_SIG ); ++tit;
- BOOST_CHECK_EQUAL( *tit, scope_name );
+ BOOST_CHECK( *tit == SCOPE_SIG );
+ ++tit;
+ BOOST_CHECK( *tit == scope_name );
}
else {
m_log_file << SCOPE_SIG << CLMN_SEP << scope_name << LINE_SEP;
@@ -164,8 +166,9 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, ALLOC_SIG ); ++tit;
- BOOST_CHECK_EQUAL( lexical_cast<std::size_t>( *tit ), s );
+ BOOST_CHECK( *tit == ALLOC_SIG );
+ ++tit;
+ BOOST_CHECK( lexical_cast<std::size_t>( *tit ) == s );
}
else {
m_log_file << ALLOC_SIG << CLMN_SEP << s << LINE_SEP;
@@ -185,8 +188,9 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, DATA_SIG ); ++tit;
- BOOST_CHECK_EQUAL( *tit, d );
+ BOOST_CHECK( *tit == DATA_SIG );
+ ++tit;
+ BOOST_CHECK( *tit == d );
}
else {
m_log_file << DATA_SIG << CLMN_SEP << d << LINE_SEP;
@@ -206,7 +210,8 @@
const_string cline( line );
string_token_iterator tit( cline, (dropped_delimeters = CLMN_SEP, kept_delimeters = dt_none));
- BOOST_CHECK_EQUAL( *tit, RETURN_SIG ); ++tit;
+ BOOST_CHECK( *tit == RETURN_SIG );
+ ++tit;
return std::string( tit->begin(), tit->size() );
}
Modified: trunk/boost/test/impl/test_main.ipp
==============================================================================
--- trunk/boost/test/impl/test_main.ipp (original)
+++ trunk/boost/test/impl/test_main.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -18,7 +18,6 @@
// Boost.Test
#include <boost/test/framework.hpp>
-#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test_suite.hpp>
// Boost
Modified: trunk/boost/test/impl/test_tools.ipp
==============================================================================
--- trunk/boost/test/impl/test_tools.ipp (original)
+++ trunk/boost/test/impl/test_tools.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -16,9 +16,13 @@
#define BOOST_TEST_TEST_TOOLS_IPP_012205GER
// Boost.Test
-#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test_log.hpp>
+#include <boost/test/tools/context.hpp>
#include <boost/test/tools/output_test_stream.hpp>
+
+#include <boost/test/tools/detail/fwd.hpp>
+#include <boost/test/tools/detail/print_helper.hpp>
+
#include <boost/test/framework.hpp>
#include <boost/test/tree/test_unit.hpp>
#include <boost/test/execution_monitor.hpp> // execution_aborted
@@ -53,6 +57,7 @@
namespace boost {
namespace test_tools {
+namespace tt_detail {
// ************************************************************************** //
// ************** print_log_value ************** //
@@ -106,8 +111,6 @@
//____________________________________________________________________________//
-namespace tt_detail {
-
// ************************************************************************** //
// ************** TOOL BOX Implementation ************** //
// ************************************************************************** //
@@ -119,7 +122,7 @@
template<typename OutStream>
void
-format_report( OutStream& os, predicate_result const& pr, unit_test::lazy_ostream const& assertion_descr,
+format_report( OutStream& os, assertion_result const& pr, unit_test::lazy_ostream const& assertion_descr,
tool_level tl, check_type ct,
std::size_t num_args, va_list args,
char const* prefix, char const* suffix )
@@ -134,20 +137,18 @@
os << ". " << pr.message();
break;
- case CHECK_BUILT_ASSERTION:
+ case CHECK_BUILT_ASSERTION: {
os << prefix << assertion_descr << suffix;
if( tl != PASS ) {
const_string details_message = pr.message();
if( !details_message.is_empty() ) {
- if( first_char( details_message ) != '\n' )
- os << " [" << details_message << "]" ;
- else
- os << "." << details_message;
+ os << details_message;
}
}
break;
+ }
case CHECK_MSG:
if( tl == PASS )
@@ -189,7 +190,7 @@
/* toler_descr = */ va_arg( args, char const* );
lazy_ostream const* toler_val = va_arg( args, lazy_ostream const* );
- os << "difference{" << pr.message() << (ct == CHECK_CLOSE ? "%" : "")
+ os << "difference{" << pr.message()
<< "} between " << arg1_descr << "{" << *arg1_val
<< "} and " << arg2_descr << "{" << *arg2_val
<< ( tl == PASS ? "} doesn't exceed " : "} exceeds " )
@@ -281,17 +282,20 @@
//____________________________________________________________________________//
bool
-check_impl( predicate_result const& pr, 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, ... )
+report_assertion( assertion_result const& ar,
+ 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, ... )
{
using namespace unit_test;
if( framework::current_test_case_id() == INV_TEST_UNIT_ID )
throw std::runtime_error( "can't use testing tools outside of test case implementation" );
- if( !!pr )
+ if( !!ar )
tl = PASS;
log_level ll;
@@ -302,7 +306,7 @@
case PASS:
ll = log_successful_tests;
prefix = "check ";
- suffix = " passed";
+ suffix = " has passed";
break;
case WARN:
ll = log_warnings;
@@ -312,12 +316,12 @@
case CHECK:
ll = log_all_errors;
prefix = "check ";
- suffix = " failed";
+ suffix = " has failed";
break;
case REQUIRE:
ll = log_fatal_errors;
prefix = "critical check ";
- suffix = " failed";
+ suffix = " has failed";
break;
default:
return true;
@@ -327,7 +331,7 @@
va_list args;
va_start( args, num_args );
- format_report( unit_test_log, pr, assertion_descr, tl, ct, num_args, args, prefix, suffix );
+ format_report( unit_test_log, ar, assertion_descr, tl, ct, num_args, args, prefix, suffix );
va_end( args );
unit_test_log << unit_test::log::end();
@@ -358,15 +362,42 @@
//____________________________________________________________________________//
+assertion_result
+format_assertion_result( const_string expr_val, const_string details )
+{
+ assertion_result res(false);
+
+ bool starts_new_line = first_char( expr_val ) == '\n';
+
+ if( !starts_new_line && !expr_val.is_empty() )
+ res.message().stream() << " [" << expr_val << "]";
+
+ if( !details.is_empty() ) {
+ if( first_char(details) != '[' )
+ res.message().stream() << ". ";
+ else
+ res.message().stream() << " ";
+
+ res.message().stream() << details;
+ }
+
+ if( starts_new_line )
+ res.message().stream() << "." << expr_val;
+
+ return res;
+}
+
+//____________________________________________________________________________//
+
BOOST_TEST_DECL std::string
-prod_report_format( predicate_result const& pr, unit_test::lazy_ostream const& assertion_descr, check_type ct, std::size_t num_args, ... )
+prod_report_format( assertion_result const& ar, unit_test::lazy_ostream const& assertion_descr, check_type ct, std::size_t num_args, ... )
{
std::ostringstream msg_buff;
va_list args;
va_start( args, num_args );
- format_report( msg_buff, pr, assertion_descr, CHECK, ct, num_args, args, "assertion ", " failed" );
+ format_report( msg_buff, ar, assertion_descr, CHECK, ct, num_args, args, "assertion ", " failed" );
va_end( args );
@@ -375,7 +406,7 @@
//____________________________________________________________________________//
-predicate_result
+assertion_result
equal_impl( char const* left, char const* right )
{
return (left && right) ? std::strcmp( left, right ) == 0 : (left == right);
@@ -385,7 +416,7 @@
#if !defined( BOOST_NO_CWCHAR )
-predicate_result
+assertion_result
equal_impl( wchar_t const* left, wchar_t const* right )
{
return (left && right) ? std::wcscmp( left, right ) == 0 : (left == right);
@@ -452,7 +483,7 @@
return res;
}
- void check_and_fill( predicate_result& res )
+ void check_and_fill( assertion_result& res )
{
if( !res.p_predicate_value )
res.message() << "Output content: \"" << m_synced_string << '\"';
@@ -471,9 +502,8 @@
m_pimpl->m_pattern.open( pattern_file_name.begin(), m );
- BOOST_WARN_MESSAGE( m_pimpl->m_pattern.is_open(),
- "Can't open pattern file " << pattern_file_name
- << " for " << (match_or_save ? "reading" : "writing") );
+ if( !m_pimpl->m_pattern.is_open() )
+ BOOST_TEST_MESSAGE( "Can't open pattern file " << pattern_file_name << " for " << (match_or_save ? "reading" : "writing") );
}
m_pimpl->m_match_or_save = match_or_save;
@@ -489,12 +519,12 @@
//____________________________________________________________________________//
-predicate_result
+assertion_result
output_test_stream::is_empty( bool flush_stream )
{
sync();
- predicate_result res( m_pimpl->m_synced_string.empty() );
+ assertion_result res( m_pimpl->m_synced_string.empty() );
m_pimpl->check_and_fill( res );
@@ -506,12 +536,12 @@
//____________________________________________________________________________//
-predicate_result
+assertion_result
output_test_stream::check_length( std::size_t length_, bool flush_stream )
{
sync();
- predicate_result res( m_pimpl->m_synced_string.length() == length_ );
+ assertion_result res( m_pimpl->m_synced_string.length() == length_ );
m_pimpl->check_and_fill( res );
@@ -523,12 +553,12 @@
//____________________________________________________________________________//
-predicate_result
+assertion_result
output_test_stream::is_equal( const_string arg, bool flush_stream )
{
sync();
- predicate_result res( const_string( m_pimpl->m_synced_string ) == arg );
+ assertion_result res( const_string( m_pimpl->m_synced_string ) == arg );
m_pimpl->check_and_fill( res );
@@ -540,12 +570,12 @@
//____________________________________________________________________________//
-predicate_result
+assertion_result
output_test_stream::match_pattern( bool flush_stream )
{
sync();
- predicate_result result( true );
+ assertion_result result( true );
if( !m_pimpl->m_pattern.is_open() ) {
result = false;
Modified: trunk/boost/test/impl/unit_test_monitor.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_monitor.ipp (original)
+++ trunk/boost/test/impl/unit_test_monitor.ipp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -18,7 +18,6 @@
// Boost.Test
#include <boost/test/unit_test_monitor.hpp>
-#include <boost/test/test_tools.hpp>
#include <boost/test/framework.hpp>
#include <boost/test/tree/test_unit.hpp>
#include <boost/test/unit_test_parameters.hpp>
Modified: trunk/boost/test/predicate_result.hpp
==============================================================================
--- trunk/boost/test/predicate_result.hpp (original)
+++ trunk/boost/test/predicate_result.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -9,8 +9,8 @@
//
// Version : $Revision$
//
-// Description : forward to new locaton
+// Description : forward to new locaton/name
// ***************************************************************************
// Boost.Test
-#include <boost/test/tools/predicate_result.hpp>
+#include <boost/test/tools/assertion_result.hpp>
Modified: trunk/boost/test/test_tools.hpp
==============================================================================
--- trunk/boost/test/test_tools.hpp (original)
+++ trunk/boost/test/test_tools.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -9,369 +9,41 @@
//
// Version : $Revision$
//
-// Description : contains definition for all test tools in test toolbox
+// Description : test tools interface
// ***************************************************************************
-#ifndef BOOST_TEST_TEST_TOOLS_HPP_012705GER
-#define BOOST_TEST_TEST_TOOLS_HPP_012705GER
+#ifndef BOOST_TEST_TOOLS_HPP_111812GER
+#define BOOST_TEST_TOOLS_HPP_111812GER
// Boost.Test
-#ifndef BOOST_TEST_PROD
-#include <boost/test/unit_test_log.hpp>
-#define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_TEST_STRINGIZE( arg )
-#else
-#define BOOST_TEST_PASSPOINT()
-#define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_STRINGIZE( arg )
-#endif
+//#define BOOST_TEST_NO_OLD_TOOLS
-// Boost
-#include <boost/preprocessor/seq/for_each.hpp>
-#include <boost/preprocessor/seq/size.hpp>
-#include <boost/preprocessor/seq/to_tuple.hpp>
-
-#include <boost/preprocessor/control/iif.hpp>
-#include <boost/preprocessor/comparison/equal.hpp>
-#include <boost/preprocessor/variadic/size.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 check_impl directly
-// 2 - no arguments; call check_impl directly
-
-#ifndef BOOST_TEST_PROD
-
-#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,PREPARE) \
-do { \
- BOOST_TEST_PASSPOINT(); \
- PREPARE \
- ::boost::test_tools::tt_detail:: \
- BOOST_PP_IF( frwd_type, check_impl, check_frwd ) ( \
- BOOST_JOIN( BOOST_TEST_TOOL_PASS_PRED, frwd_type )( P, ARGS ), \
- ::boost::unit_test::lazy_ostream::instance() << 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::dummy_cond ) \
-/**/
+#if !defined(BOOST_PP_VARIADICS)
+//#define BOOST_TEST_NO_NEW_TOOLS
#endif
-//____________________________________________________________________________//
+// #define BOOST_TEST_TOOLS_UNDER_DEBUGGER
+// #define BOOST_TEST_TOOLS_DEBUGGABLE
-#define BOOST_WARN( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (P), BOOST_TEST_TOOLS_STRINGIZE( P ), WARN, CHECK_PRED, _, BOOST_PP_EMPTY() )
-#define BOOST_CHECK( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (P), BOOST_TEST_TOOLS_STRINGIZE( P ), CHECK, CHECK_PRED, _, BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (P), BOOST_TEST_TOOLS_STRINGIZE( P ), REQUIRE, CHECK_PRED, _, BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
-#define BOOST_TEST_BUILD_ASSERTION( P ) \
- ::boost::test_tools::assertion::expression const& E = \
- ::boost::test_tools::assertion::seed() ->* P; \
-/**/
-#else
-#define BOOST_TEST_BUILD_ASSERTION( P ) \
- auto const& E = \
- ::boost::test_tools::assertion::seed() ->* P; \
-/**/
-#endif
+#include <boost/test/tools/context.hpp>
-#define BOOST_WARN_ASSERTION( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (E.evaluate()), BOOST_TEST_TOOLS_STRINGIZE( P ), WARN, \
- CHECK_BUILT_ASSERTION, _, BOOST_TEST_BUILD_ASSERTION( P ) ) \
-/**/
-#define BOOST_CHECK_ASSERTION( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (E.evaluate()), BOOST_TEST_TOOLS_STRINGIZE( P ), CHECK, \
- CHECK_BUILT_ASSERTION, _, BOOST_TEST_BUILD_ASSERTION( P ) ) \
-/**/
-#define BOOST_REQUIRE_ASSERTION( P ) BOOST_TEST_TOOL_IMPL( 2, \
- (E.evaluate()), BOOST_TEST_TOOLS_STRINGIZE( P ), REQUIRE, \
- CHECK_BUILT_ASSERTION, _, BOOST_TEST_BUILD_ASSERTION( P ) ) \
-/**/
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, WARN, CHECK_MSG, _, BOOST_PP_EMPTY() )
-#define BOOST_CHECK_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, CHECK, CHECK_MSG, _, BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_MESSAGE( P, M ) BOOST_TEST_TOOL_IMPL( 2, (P), M, REQUIRE, CHECK_MSG, _, BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#if BOOST_PP_VARIADICS
-
-#if BOOST_PP_VARIADICS_MSVC
-#define BOOST_TEST_INVOKE_TOOL( tool, ... ) BOOST_PP_CAT( tool (__VA_ARGS__), )
-#else
-#define BOOST_TEST_INVOKE_TOOL( tool, ... ) tool (__VA_ARGS__)
-#endif
-
-#define BOOST_TEST_WARN( ... ) BOOST_TEST_INVOKE_TOOL( \
- BOOST_PP_IIF( \
- BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),2), \
- BOOST_WARN_MESSAGE, \
- BOOST_WARN_ASSERTION), __VA_ARGS__ ) \
-/**/
-#define BOOST_TEST( ... ) BOOST_TEST_INVOKE_TOOL( \
- BOOST_PP_IIF( \
- BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),2), \
- BOOST_CHECK_MESSAGE, \
- BOOST_CHECK_ASSERTION), __VA_ARGS__ ) \
-/**/
-#define BOOST_TEST_REQUIRE( ... ) BOOST_TEST_INVOKE_TOOL( \
- BOOST_PP_IIF( \
- BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),2), \
- BOOST_REQUIRE_MESSAGE, \
- BOOST_REQUIRE_ASSERTION), __VA_ARGS__ ) \
-/**/
-
-#else
-
-#define BOOST_TEST_WARN( P ) BOOST_WARN_ASSERTION( P )
-#define BOOST_TEST( P ) BOOST_CHECK_ASSERTION( P )
-#define BOOST_TEST_REQUIRE( P ) BOOST_REQUIRE_ASSERTION( P )
+#ifndef BOOST_TEST_NO_OLD_TOOLS
+# include <boost/test/tools/old/interface.hpp>
+# include <boost/test/tools/old/impl.hpp>
+# include <boost/test/tools/detail/print_helper.hpp>
#endif
-//____________________________________________________________________________//
-
-#define BOOST_ERROR( M ) BOOST_CHECK_MESSAGE( false, M )
-#define BOOST_FAIL( M ) BOOST_REQUIRE_MESSAGE( false, M )
+#ifndef BOOST_TEST_NO_NEW_TOOLS
+# include <boost/test/tools/interface.hpp>
+# include <boost/test/tools/assertion.hpp>
+
+# include <boost/test/tools/detail/fwd.hpp>
+# include <boost/test/tools/detail/print_helper.hpp>
+# include <boost/test/tools/detail/it_pair.hpp>
-//____________________________________________________________________________//
-
-#define BOOST_CHECK_THROW_IMPL( S, E, P, prefix, TL ) \
-do { \
- try { \
- BOOST_TEST_PASSPOINT(); \
- S; \
- BOOST_TEST_TOOL_IMPL( 2, false, "exception " BOOST_STRINGIZE(E) " is expected", \
- TL, CHECK_MSG, _, BOOST_PP_EMPTY() ); \
- } catch( E const& ex ) { \
- ::boost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \
- BOOST_TEST_TOOL_IMPL( 2, P, prefix BOOST_STRINGIZE( E ) " is caught", \
- TL, CHECK_MSG, _ , BOOST_PP_EMPTY() ); \
- } \
-} while( ::boost::test_tools::dummy_cond ) \
-/**/
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", WARN )
-#define BOOST_CHECK_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", CHECK )
-#define BOOST_REQUIRE_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", REQUIRE )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", WARN )
-#define BOOST_CHECK_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", CHECK )
-#define BOOST_REQUIRE_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", 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, _, BOOST_PP_EMPTY() ); \
- } catch( ... ) { \
- BOOST_TEST_TOOL_IMPL( 2, false, "exception thrown by " BOOST_STRINGIZE( S ), \
- TL, CHECK_MSG, _, BOOST_PP_EMPTY() ); \
- } \
-} while( ::boost::test_tools::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), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::equal_impl_frwd(), "", CHECK, CHECK_EQUAL, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_EQUAL( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::equal_impl_frwd(), "", REQUIRE, CHECK_EQUAL, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_NE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_LT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_LE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_GT( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_GE( L, R ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", WARN, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_CLOSE( L, R, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE, (L)(R)(::boost::math::fpc::percent_tolerance(T)), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_CLOSE_FRACTION(L, R, T) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", WARN, CHECK_CLOSE_FRACTION, (L)(R)(T), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_CLOSE_FRACTION(L, R, T) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", CHECK, CHECK_CLOSE_FRACTION, (L)(R)(T), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_CLOSE_FRACTION(L,R,T) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_close, "", REQUIRE, CHECK_CLOSE_FRACTION, (L)(R)(T), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_small, "", WARN, CHECK_SMALL, (FPV)(T), BOOST_PP_EMPTY() )
-#define BOOST_CHECK_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_small, "", CHECK, CHECK_SMALL, (FPV)(T), BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_SMALL( FPV, T ) BOOST_TEST_TOOL_IMPL( 0, \
- ::boost::test_tools::check_is_small, "", REQUIRE, CHECK_SMALL, (FPV)(T), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_WARN_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
- P, BOOST_TEST_TOOLS_STRINGIZE( P ), WARN, CHECK_PRED_WITH_ARGS, ARGS, BOOST_PP_EMPTY() )
-#define BOOST_CHECK_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
- P, BOOST_TEST_TOOLS_STRINGIZE( P ), CHECK, CHECK_PRED_WITH_ARGS, ARGS, BOOST_PP_EMPTY() )
-#define BOOST_REQUIRE_PREDICATE( P, ARGS ) BOOST_TEST_TOOL_IMPL( 0, \
- P, BOOST_TEST_TOOLS_STRINGIZE( P ), REQUIRE, CHECK_PRED_WITH_ARGS, ARGS, BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#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), BOOST_PP_EMPTY() ) \
-/**/
-#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), BOOST_PP_EMPTY() ) \
-/**/
-#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), BOOST_PP_EMPTY() )\
-/**/
-
-//____________________________________________________________________________//
-
-#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), BOOST_PP_EMPTY() )
-#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), BOOST_PP_EMPTY() )
-#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), BOOST_PP_EMPTY() )
-
-//____________________________________________________________________________//
-
-#define BOOST_IS_DEFINED( symb ) ::boost::test_tools::tt_detail::is_defined_impl( #symb, BOOST_STRINGIZE(= symb) )
-
-//____________________________________________________________________________//
-
-#define BOOST_TEST_INFO( context_descr ) \
- ::boost::unit_test::framework::add_context( ::boost::unit_test::lazy_ostream::instance() << 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::unit_test::lazy_ostream::instance() << context_descr ) )
-
-//____________________________________________________________________________//
-
-#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
-namespace boost { namespace test_tools { \
-template<> \
-struct print_log_value<the_type > { \
- void operator()( std::ostream&, the_type const& ) {} \
-}; \
-}} \
-/**/
-
-//____________________________________________________________________________//
-
-// ***************************** //
-// deprecated interface
-
-#define BOOST_BITWISE_EQUAL( L, R ) BOOST_CHECK_BITWISE_EQUAL( L, R )
-#define BOOST_MESSAGE( M ) BOOST_TEST_MESSAGE( M )
-#define BOOST_CHECKPOINT( M ) BOOST_TEST_CHECKPOINT( M )
-
-#include <boost/test/tools/impl.hpp>
-
-#include <boost/test/detail/enable_warnings.hpp>
+# include <boost/test/tools/detail/bitwise_manip.hpp>
+# include <boost/test/tools/detail/tolerance_manip.hpp>
+#endif
-#endif // BOOST_TEST_TEST_TOOLS_HPP_012705GER
+#endif // BOOST_TEST_TOOLS_HPP_111812GER
Modified: trunk/boost/test/tools/assertion.hpp
==============================================================================
--- trunk/boost/test/tools/assertion.hpp (original)
+++ trunk/boost/test/tools/assertion.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -17,12 +17,18 @@
// Boost.Test
#include <boost/test/utils/is_forward_iterable.hpp>
+#include <boost/test/utils/is_cstring.hpp>
+#include <boost/test/utils/basic_cstring/compare.hpp>
+
+#include <boost/test/tools/floating_point_comparison.hpp>
+#include <boost/test/tools/fpc_tolerance.hpp>
// Boost
#include <boost/mpl/assert.hpp>
#include <boost/utility/declval.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/is_floating_point.hpp>
// STL
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
@@ -150,7 +156,8 @@
Rhs const& rhs) \
{ \
lhs.report( ostr ); \
- ostr << revert() << rhs; \
+ ostr << revert() \
+ << tt_detail::print_helper( rhs ); \
} \
\
static char const* revert() \
@@ -165,11 +172,13 @@
//____________________________________________________________________________//
+namespace op_detail {
+
template <typename OP, typename Lhs, typename Rhs>
-inline predicate_result
+inline assertion_result
compare_collections( Lhs const& lhs, Rhs const& rhs )
{
- predicate_result pr( true );
+ assertion_result pr( true );
if( lhs.size() != rhs.size() ) {
pr = false;
@@ -192,51 +201,206 @@
return pr;
}
+} // namespace op_detail
+
//____________________________________________________________________________//
-#define DEFINE_COLLECTION_COMPARISON( oper, name, _ ) \
-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 predicate_result result_type; \
- \
- static predicate_result \
- eval( Lhs const& lhs, Rhs const& rhs) \
- { \
- typedef name<typename boost::remove_reference<Lhs> \
- ::type::value_type, \
- typename boost::remove_reference<Rhs> \
- ::type::value_type> elem_comp_op; \
- return compare_collections<elem_comp_op>(lhs, rhs); \
- } \
- \
- template<typename PrevExprType> \
- static void \
- report( std::ostream&, \
- PrevExprType const&, \
- Rhs const& ) {} \
-}; \
+#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
+
//____________________________________________________________________________//
+#define DEFINE_COLLECTION_COMPARISON( oper, name, _ ) \
+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; \
+ \
+ static assertion_result \
+ eval( Lhs const& lhs, Rhs const& rhs) \
+ { \
+ typedef name<typename Lhs::value_type, \
+ typename Rhs::value_type> OP; \
+ return op_detail::compare_collections<OP>(lhs, rhs); \
+ } \
+ \
+ template<typename PrevExprType> \
+ static void \
+ report( std::ostream&, \
+ PrevExprType const&, \
+ Rhs const& ) {} \
+}; \
+/**/
+
BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_COLLECTION_COMPARISON )
+#undef DEFINE_COLLECTION_COMPARISON
-} // namespace op
+//____________________________________________________________________________//
-// ************************************************************************** //
-// ************** assertion::expression ************** //
-// ************************************************************************** //
+namespace op_detail {
-#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
-class expression {
-public:
- // expression interface
- virtual predicate_result evaluate() const = 0;
+template<typename OP, typename FPT>
+struct compare_fpv {
+ enum { cmp_direct = true };
+
+ template <typename Lhs, typename Rhs>
+ static assertion_result
+ compare( Lhs const& lhs, Rhs const& rhs )
+ {
+ 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.failed_fraction() << " > " << P.fraction_tolerance() << ']';
+ return ar;
+ }
+
+ static assertion_result
+ compare_0( FPT const& fpv )
+ {
+ 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;
+ }
};
-#endif
+
+//____________________________________________________________________________//
+
+template<typename Lhs, typename Rhs, typename FPT>
+struct compare_fpv<op::NE<Lhs,Rhs>,FPT> {
+ enum { cmp_direct = false };
+
+ static assertion_result
+ compare( Lhs const& lhs, Rhs const& rhs )
+ {
+ fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_STRONG );
+
+ assertion_result ar( !P( lhs, rhs ) );
+ if( !ar )
+ ar.message() << "Relative difference is within tolerance ["
+ << P.failed_fraction() << " < " << fpc_tolerance<FPT>() << ']';
+ return ar;
+ }
+
+ static assertion_result
+ compare_0( FPT const& fpv )
+ {
+ 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;
+ }
+};
+
+//____________________________________________________________________________//
+
+} // namespace op_detail
+
+#define DEFINE_FPV_COMPARISON( oper, name, rev ) \
+template<typename Lhs,typename Rhs> \
+struct name<Lhs,Rhs,typename boost::enable_if_c< \
+ is_floating_point<Lhs>::value && \
+ is_floating_point<Rhs>::value>::type> { \
+ typedef typename numeric::conversion_traits<Lhs,Rhs \
+ >::supertype FPT; \
+ typedef name<Lhs,Rhs> OP; \
+public: \
+ 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 == Lhs() ) \
+ return op_detail::compare_fpv<OP,Rhs>::compare_0(rhs); \
+ \
+ if( rhs == Rhs() ) \
+ return op_detail::compare_fpv<OP,Lhs>::compare_0(lhs); \
+ \
+ bool direct_res = eval_direct( lhs, rhs ); \
+ \
+ if(direct_res && op_detail::compare_fpv<OP,FPT>::cmp_direct \
+ || fpc_tolerance<FPT>() == FPT()) \
+ return direct_res; \
+ \
+ return op_detail::compare_fpv<OP,FPT>::compare(lhs, 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_FPV_COMPARISON )
+#undef DEFINE_FPV_COMPARISON
+
+//____________________________________________________________________________//
+
+} // namespace op
// ************************************************************************** //
// ************** assertion::expression_base ************** //
@@ -246,35 +410,36 @@
template<typename Lhs, typename Rhs, typename OP> class binary_expr;
template<typename ExprType,typename ValType>
-class expression_base
-#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
-: public expression
-#endif
-{
+class expression_base {
public:
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
#define ADD_OP_SUPPORT( oper, name, _ ) \
template<typename T> \
- binary_expr<ExprType,T,op::name<ValType,T> > \
- operator oper( T&& rhs ) const \
+ binary_expr<ExprType,T, \
+ op::name<ValType,typename remove_reference<T>::type> > \
+ operator oper( T&& rhs ) \
{ \
- return binary_expr<ExprType,T,op::name<ValType,T> >( \
- *static_cast<ExprType const*>(this), \
- std::forward<T>(rhs) ); \
+ return binary_expr<ExprType,T, \
+ op::name<ValType,typename remove_reference<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,T,op::name<ValType,T> > \
+ binary_expr<ExprType,typename decay<T const>::type, \
+ op::name<ValType,typename decay<T const>::type> > \
operator oper( T const& rhs ) const \
{ \
- return binary_expr<ExprType,T,op::name<ValType,T> >( \
- *static_cast<ExprType const*>(this), \
- rhs ); \
+ typedef typename decay<T const>::type Rhs; \
+ return binary_expr<ExprType,Rhs,op::name<ValType,Rhs> > \
+ ( *static_cast<ExprType const*>(this), \
+ rhs ); \
} \
/**/
#endif
@@ -282,10 +447,11 @@
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& )
+ operator ||( T const& rhs )
{
BOOST_MPL_ASSERT_MSG(false, CANT_USE_LOGICAL_OPERATOR_OR_WITHIN_THIS_TESTING_TOOL, () );
@@ -294,7 +460,7 @@
template<typename T>
ExprType&
- operator &&( T const& )
+ operator &&( T const& rhs )
{
BOOST_MPL_ASSERT_MSG(false, CANT_USE_LOGICAL_OPERATOR_AND_WITHIN_THIS_TESTING_TOOL, () );
@@ -307,6 +473,7 @@
return false;
}
+#endif
};
// ************************************************************************** //
@@ -315,20 +482,24 @@
// simple value expression
template<typename T>
-class value_expr : public expression_base<value_expr<T>,T> {
+class value_expr : public expression_base<value_expr<T>,typename remove_reference<T>::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
{}
+#endif
// Specific expresson interface
T const& value() const
@@ -337,7 +508,7 @@
}
void report( std::ostream& ostr ) const
{
- ostr << m_value;
+ ostr << tt_detail::print_helper( m_value );
}
// Mutating operators
@@ -356,23 +527,22 @@
#undef ADD_OP_SUPPORT
// expression interface
-#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
- virtual predicate_result evaluate() const
-#else
- predicate_result evaluate() const
-#endif
+ assertion_result evaluate( bool no_message = false ) const
{
- predicate_result res( value() );
- if( !res )
- format_message( res.message(), value() );
+ assertion_result res( value() );
+ if( no_message || res )
+ return 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& , bool ) {}
+ 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;
@@ -384,16 +554,19 @@
// binary expression
template<typename LExpr, typename Rhs, typename OP>
-class binary_expr : public expression_base<binary_expr<LExpr,Rhs,OP>,typename OP::result_type>
-{
+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( LExpr const& lhs, Rhs&& rhs )
- : m_lhs( lhs )
+ 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
@@ -413,19 +586,21 @@
return OP::report( ostr, m_lhs, m_rhs );
}
-#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
- virtual predicate_result evaluate() const
-#else
- predicate_result evaluate() const
-#endif
+ assertion_result evaluate( bool no_message = false ) const
{
- predicate_result res( value() );
- if( !res )
- report( res.message().stream() );
+ assertion_result const expr_res( value() );
+ if( no_message || expr_res )
+ return expr_res;
+
+ wrap_stringstream buff;
+ report( buff.stream() );
- return res;
+ 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;
Copied: trunk/boost/test/tools/assertion_result.hpp (from r82045, /trunk/boost/test/tools/predicate_result.hpp)
==============================================================================
--- /trunk/boost/test/tools/predicate_result.hpp (original)
+++ trunk/boost/test/tools/assertion_result.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -35,22 +35,22 @@
namespace test_tools {
// ************************************************************************** //
-// ************** predicate_result ************** //
+// ************** assertion_result ************** //
// ************************************************************************** //
-class BOOST_TEST_DECL predicate_result {
+class BOOST_TEST_DECL assertion_result {
typedef unit_test::const_string const_string;
struct dummy { void nonnull() {} };
typedef void (dummy::*safe_bool)();
public:
// Constructor
- predicate_result( bool pv_ )
+ assertion_result( bool pv_ )
: p_predicate_value( pv_ )
{}
template<typename BoolConvertable>
- predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
+ assertion_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
// Access methods
bool operator!() const { return !p_predicate_value; }
@@ -58,7 +58,7 @@
operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
// Public properties
- BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value;
+ BOOST_READONLY_PROPERTY( bool, (assertion_result) ) p_predicate_value;
// Access methods
bool has_empty_message() const { return !m_message; }
@@ -76,6 +76,8 @@
shared_ptr<wrap_stringstream> m_message;
};
+typedef assertion_result predicate_result;
+
} // namespace test_tools
} // namespace boost
Added: trunk/boost/test/tools/context.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/context.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,65 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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
Added: trunk/boost/test/tools/detail/bitwise_manip.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/bitwise_manip.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,114 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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 : bitwose 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 ************** //
+// ************************************************************************** //
+
+struct bitwise {};
+
+//____________________________________________________________________________//
+
+inline int
+operator<<( unit_test::lazy_ostream const&, bitwise ) { return 0; }
+
+//____________________________________________________________________________//
+
+namespace tt_detail {
+
+template<typename Lhs, typename Rhs, typename E>
+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 in a 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;
+}
+
+//____________________________________________________________________________//
+
+template<typename T1, typename T2, typename T3, typename T4>
+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& at, 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
Added: trunk/boost/test/tools/detail/expression_holder.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/expression_holder.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,70 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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
Added: trunk/boost/test/tools/detail/fwd.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/fwd.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,121 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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
Added: trunk/boost/test/tools/detail/indirections.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/indirections.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,94 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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
Added: trunk/boost/test/tools/detail/it_pair.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/it_pair.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,73 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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; }
+ 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
Added: trunk/boost/test/tools/detail/print_helper.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/print_helper.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,198 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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/type_traits/is_array.hpp>
+#include <boost/type_traits/is_function.hpp>
+#include <boost/type_traits/is_abstract.hpp>
+
+#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 {
+ 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
Added: trunk/boost/test/tools/detail/tolerance_manip.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/detail/tolerance_manip.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,121 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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 tolerance manipulator implementation
+// ***************************************************************************
+
+#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>
+
+// Boost
+#include <boost/type_traits/is_floating_point.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 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( is_floating_point<FPT>::value );
+
+ return tolerance_manip<FPT>( v * static_cast<FPT>(0.01) );
+}
+
+//____________________________________________________________________________//
+
+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
+
+template<typename FPT>
+inline tt_detail::tolerance_manip<FPT>
+tolerance( FPT v )
+{
+ BOOST_STATIC_ASSERT( is_floating_point<FPT>::value );
+
+ return tt_detail::tolerance_manip<FPT>( v );
+}
+
+//____________________________________________________________________________//
+
+template<typename FPT>
+inline tt_detail::tolerance_manip<FPT>
+tolerance( fpc::percent_tolerance_t<FPT> v )
+{
+ BOOST_STATIC_ASSERT( is_floating_point<FPT>::value );
+
+ return tt_detail::tolerance_manip<FPT>( v.m_value * static_cast<FPT>(0.01) );
+}
+
+//____________________________________________________________________________//
+
+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
Modified: trunk/boost/test/tools/floating_point_comparison.hpp
==============================================================================
--- trunk/boost/test/tools/floating_point_comparison.hpp (original)
+++ trunk/boost/test/tools/floating_point_comparison.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -17,7 +17,7 @@
// Boost.Test
#include <boost/test/detail/global_typedef.hpp>
-#include <boost/test/tools/predicate_result.hpp>
+#include <boost/test/tools/assertion_result.hpp>
// Boost
#include <boost/limits.hpp> // for std::numeric_limits
@@ -164,6 +164,20 @@
//____________________________________________________________________________//
// ************************************************************************** //
+// ************** fp_comp_type ************** //
+// ************************************************************************** //
+
+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( !is_integral<type>::value );
+};
+
+// ************************************************************************** //
// ************** close_at_tolerance ************** //
// ************************************************************************** //
@@ -198,7 +212,9 @@
? (fraction_of_right <= m_fraction_tolerance && fraction_of_left <= m_fraction_tolerance)
: (fraction_of_right <= m_fraction_tolerance || fraction_of_left <= m_fraction_tolerance) );
- if( !res )
+ if( res )
+ m_failed_fraction = (fraction_of_right > m_fraction_tolerance ? fraction_of_right : fraction_of_left);
+ else
m_failed_fraction = (fraction_of_right > m_fraction_tolerance ? fraction_of_right : fraction_of_left);
return res;
@@ -219,20 +235,13 @@
bool
is_close_to( FPT1 left, FPT2 right, ToleranceType tolerance )
{
- // 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 FPT;
- BOOST_STATIC_ASSERT( !is_integral<FPT>::value );
-
- return fpc::close_at_tolerance<FPT>( tolerance, FPC_STRONG )( left, right );
+ return fpc::close_at_tolerance<typename fpc::comp_supertype<FPT1,FPT2>::type>( tolerance, FPC_STRONG )( left, right );
}
//____________________________________________________________________________//
// ************************************************************************** //
-// ************** close_at_tolerance ************** //
+// ************** small_with_tolerance ************** //
// ************************************************************************** //
template<typename FPT>
@@ -242,7 +251,7 @@
typedef bool result_type;
// Constructor
- explicit small_with_tolerance( FPT tolerance )
+ explicit small_with_tolerance( FPT tolerance ) // <= absolute tolerance
: m_tolerance( tolerance )
{
BOOST_ASSERT( m_tolerance >= 0 ); // no reason for the tolerance to be negative
@@ -274,61 +283,6 @@
} // namespace fpc
} // namespace math
-
-namespace test_tools {
-
-namespace fpc = math::fpc;
-
-// ************************************************************************** //
-// ************** check_is_close ************** //
-// ************************************************************************** //
-
-struct BOOST_TEST_DECL check_is_close_t {
- // Public typedefs
- typedef bool result_type;
-
- template<typename FPT1, typename FPT2, typename ToleranceType>
- predicate_result
- operator()( FPT1 left, FPT2 right, ToleranceType tolerance ) const
- {
- predicate_result pr( fpc::is_close_to( left, right, tolerance ) );
-
- if( !pr )
- pr.message() << tolerance;
-
- return pr;
- }
-};
-
-namespace {
-check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant<check_is_close_t>::value;
-}
-
-//____________________________________________________________________________//
-
-// ************************************************************************** //
-// ************** 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 );
- }
-};
-
-namespace {
-check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant<check_is_small_t>::value;
-}
-
-//____________________________________________________________________________//
-
-} // namespace test_tools
} // namespace boost
#include <boost/test/detail/enable_warnings.hpp>
Added: trunk/boost/test/tools/fpc_tolerance.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/fpc_tolerance.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,103 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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>
+FPT&
+fpc_tolerance()
+{
+ static FPT s_value = FPT();
+ 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>( v.m_value * static_cast<FPT>(0.01) ) ) );
+}
+
+//____________________________________________________________________________//
+
+} // 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
Deleted: trunk/boost/test/tools/impl.hpp
==============================================================================
Binary file. No diff available.
Added: trunk/boost/test/tools/interface.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/interface.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,365 @@
+// (C) Copyright Gennadiy Rozental 2001-2012.
+// 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_OLD_TOOLBOX_HPP_111712GER
+#define BOOST_TEST_OLD_TOOLBOX_HPP_111712GER
+
+// Boost.Test
+#include <boost/test/unit_test_log.hpp>
+#ifdef BOOST_TEST_TOOLS_DEBUGGABLE
+#include <boost/test/debug.hpp>
+#endif
+
+// Boost
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/variadic/size.hpp>
+
+// STL
+#ifdef BOOST_TEST_NO_OLD_TOOLS
+#include <iterator>
+#endif // BOOST_TEST_NO_OLD_TOOLS
+
+#include <boost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** BOOST_TEST_<level> ************** //
+// ************************************************************************** //
+
+#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
+#define BOOST_TEST_BUILD_ASSERTION( P ) \
+ ::boost::test_tools::tt_detail::expression_holder const& E= \
+ ::boost::test_tools::tt_detail::hold_expression( \
+ ::boost::test_tools::assertion::seed() ->* P ) \
+/**/
+#else
+#define BOOST_TEST_BUILD_ASSERTION( P ) \
+ auto const& E = ::boost::test_tools::assertion::seed()->*P \
+/**/
+#endif
+
+//____________________________________________________________________________//
+
+#if BOOST_PP_VARIADICS_MSVC
+# define BOOST_TEST_INVOKE_VARIADIC( tool, ... ) BOOST_PP_CAT( tool (__VA_ARGS__), )
+#else
+# define BOOST_TEST_INVOKE_VARIADIC( tool, ... ) tool (__VA_ARGS__)
+#endif
+
+//____________________________________________________________________________//
+
+// 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_BUILD_ASSERTION( P ); \
+ ::boost::test_tools::tt_detail:: \
+ report_assertion( \
+ E.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_BUILD_ASSERTION( P ); \
+ ::boost::test_tools::tt_detail:: \
+ report_assertion( \
+ ::boost::test_tools::tt_detail::assertion_evaluate(E) \
+ << 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( P, level ) \
+ BOOST_TEST_TOOL_DIRECT_IMPL( P, level, BOOST_TEST_STRINGIZE( P ) ) \
+/**/
+
+#elif defined(BOOST_TEST_TOOLS_DEBUGGABLE)
+
+#define BOOST_TEST_TOOL_UNIV( P, level ) \
+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, __VA_ARGS__ ); \
+} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
+/**/
+
+#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_VARIADIC( \
+ BOOST_PP_IIF( \
+ BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
+ BOOST_TEST_TOOL_UNIV, \
+ BOOST_TEST_TOOL_UNIV_EX), WARN, __VA_ARGS__ ) \
+/**/
+#define BOOST_TEST_CHECK( ... ) BOOST_TEST_INVOKE_VARIADIC( \
+ BOOST_PP_IIF( \
+ BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
+ BOOST_TEST_TOOL_UNIV, \
+ BOOST_TEST_TOOL_UNIV_EX), CHECK, __VA_ARGS__ ) \
+/**/
+#define BOOST_TEST_REQUIRE( ... ) BOOST_TEST_INVOKE_VARIADIC( \
+ BOOST_PP_IIF( \
+ BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
+ BOOST_TEST_TOOL_UNIV, \
+ BOOST_TEST_TOOL_UNIV_EX), REQUIRE, __VA_ARGS__ ) \
+/**/
+
+#define BOOST_TEST( ... ) BOOST_TEST_INVOKE_VARIADIC( \
+ BOOST_PP_IIF( \
+ BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),1), \
+ 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() ) \
+/**/
+
+#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) ) \
+/**/
+
+#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) ) \
+/**/
+
+#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) ) \
+/**/
+
+//____________________________________________________________________________//
+
+#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_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_OLD_TOOLBOX_HPP_111712GER
Added: trunk/boost/test/tools/old/impl.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/old/impl.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,344 @@
+// (C) Copyright Gennadiy Rozental 2011-2012.
+// 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/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>
+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 in a position " << pos << ": " << *left_begin << " != " << *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 in a 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;
+ }
+};
+
+//____________________________________________________________________________//
+
+} // 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 fpc::comp_supertype<FPT1,FPT2>::type> pred( tolerance, fpc::FPC_STRONG );
+
+ assertion_result ar( pred( left, right ) );
+
+ if( !ar )
+ ar.message() << pred.failed_fraction();
+
+ return ar;
+ }
+};
+
+//____________________________________________________________________________//
+
+template<typename FPT1, typename FPT2, typename ToleranceType>
+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>
+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
Added: trunk/boost/test/tools/old/interface.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/tools/old/interface.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,278 @@
+// (C) Copyright Gennadiy Rozental 2001-2012.
+// 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, prefix, TL ) \
+do { \
+ try { \
+ BOOST_TEST_PASSPOINT(); \
+ S; \
+ BOOST_TEST_TOOL_IMPL( 2, false, "exception " BOOST_STRINGIZE(E) " is expected", \
+ TL, CHECK_MSG, _ ); \
+ } catch( E const& ex ) { \
+ ::boost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \
+ BOOST_TEST_TOOL_IMPL( 2, P, prefix BOOST_STRINGIZE( E ) " is caught", \
+ TL, CHECK_MSG, _ ); \
+ } \
+} while( ::boost::test_tools::tt_detail::dummy_cond() ) \
+/**/
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", WARN )
+#define BOOST_CHECK_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", CHECK )
+#define BOOST_REQUIRE_THROW( S, E ) BOOST_CHECK_THROW_IMPL( S, E, true, "exception ", REQUIRE )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", WARN )
+#define BOOST_CHECK_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", CHECK )
+#define BOOST_REQUIRE_EXCEPTION( S, E, P ) BOOST_CHECK_THROW_IMPL( S, E, P( ex ), "incorrect exception ", 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, "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
Modified: trunk/boost/test/tools/output_test_stream.hpp
==============================================================================
--- trunk/boost/test/tools/output_test_stream.hpp (original)
+++ trunk/boost/test/tools/output_test_stream.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -18,7 +18,7 @@
// Boost.Test
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/utils/wrap_stringstream.hpp>
-#include <boost/test/tools/predicate_result.hpp>
+#include <boost/test/tools/assertion_result.hpp>
// STL
#include <cstddef> // for std::size_t
@@ -48,10 +48,10 @@
~output_test_stream();
// checking function
- predicate_result is_empty( bool flush_stream = true );
- predicate_result check_length( std::size_t length, bool flush_stream = true );
- predicate_result is_equal( const_string arg_, bool flush_stream = true );
- predicate_result match_pattern( bool flush_stream = true );
+ assertion_result is_empty( bool flush_stream = true );
+ assertion_result check_length( std::size_t length, bool flush_stream = true );
+ assertion_result is_equal( const_string arg_, bool flush_stream = true );
+ assertion_result match_pattern( bool flush_stream = true );
// explicit flush
void flush();
Deleted: trunk/boost/test/tools/predicate_result.hpp
==============================================================================
--- trunk/boost/test/tools/predicate_result.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
+++ (empty file)
@@ -1,84 +0,0 @@
-// (C) Copyright Gennadiy Rozental 2001-2012.
-// 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$
-//
-// Description : 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 {
-
-// ************************************************************************** //
-// ************** predicate_result ************** //
-// ************************************************************************** //
-
-class BOOST_TEST_DECL predicate_result {
- typedef unit_test::const_string const_string;
- struct dummy { void nonnull() {} };
- typedef void (dummy::*safe_bool)();
-
-public:
- // Constructor
- predicate_result( bool pv_ )
- : p_predicate_value( pv_ )
- {}
-
- template<typename BoolConvertable>
- predicate_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, (predicate_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;
-};
-
-} // namespace test_tools
-} // namespace boost
-
-#include <boost/test/detail/enable_warnings.hpp>
-
-#endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
Modified: trunk/boost/test/tools/prod_tools.hpp
==============================================================================
--- trunk/boost/test/tools/prod_tools.hpp (original)
+++ trunk/boost/test/tools/prod_tools.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -64,7 +64,7 @@
#define BOOST_TEST_TOOL_REPORT_FORMAT( frwd_type, pred_res, assertion_descr, CT, ARGS ) \
::boost::test_tools::tt_detail::prod_report_format( pred_res, \
- ::boost::unit_test::lazy_ostream::instance() << assertion_descr, \
+ BOOST_TEST_LAZY_MSG( assertion_descr ), \
::boost::test_tools::tt_detail::CT, \
BOOST_JOIN( BOOST_TEST_TOOL_REPORT_ARGS, frwd_type )( ARGS ) ) \
/**/
@@ -85,7 +85,7 @@
// 1 - args exists, but do not need to be forwarded
#define BOOST_TEST_TOOL_IMPL1( P, assertion_descr, TL, CT, ARGS ) \
- if( ::boost::test_tools::predicate_result const& pr = P BOOST_PP_SEQ_TO_TUPLE( ARGS ) ) \
+ if( ::boost::test_tools::assertion_result const& pr = P BOOST_PP_SEQ_TO_TUPLE( ARGS ) ) \
((void)0); \
else BOOST_JOIN( BOOST_JOIN( BOOST_TEST_TOOL_REPORT_, TL), _FAILURE)( \
BOOST_TEST_TOOL_REPORT_FORMAT( 1, pr, assertion_descr, CT, ARGS ) ) \
@@ -95,7 +95,7 @@
// 2 - assertion with no arguments;
#define BOOST_TEST_TOOL_IMPL2( P, assertion_descr, TL, CT, _ ) \
- if( ::boost::test_tools::predicate_result const& pr = P ) \
+ if( ::boost::test_tools::assertion_result const& pr = P ) \
((void)0); \
else BOOST_JOIN( BOOST_JOIN( BOOST_TEST_TOOL_REPORT_, TL), _FAILURE)( \
BOOST_TEST_TOOL_REPORT_FORMAT( 2, pr, assertion_descr, CT, _ ) ) \
@@ -117,7 +117,7 @@
// ************************************************************************** //
BOOST_TEST_DECL std::string
-prod_report_format( predicate_result const& pr,
+prod_report_format( assertion_result const& pr,
unit_test::lazy_ostream const& assertion_descr,
check_type ct, std::size_t num_args, ... );
@@ -158,13 +158,13 @@
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), FUNC_PARAMS, _ ) ) \
: m_failure_descr( 0 ) \
{ \
- predicate_result const& pr = \
+ assertion_result const& pr = \
P( BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), PRED_PARAMS, _ ) ); \
if( pr ) return; \
\
m_failure_descr = new std::string; \
*m_failure_descr = prod_report_format( pr, \
- ::boost::unit_test::lazy_ostream::instance() << assertion_descr, \
+ BOOST_TEST_LAZY_MSG( assertion_descr ), \
ct, \
BOOST_PP_ADD( n, 1 ) \
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), ARG_INFO, _ ) ); \
Modified: trunk/boost/test/tree/decorator.hpp
==============================================================================
--- trunk/boost/test/tree/decorator.hpp (original)
+++ trunk/boost/test/tree/decorator.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -228,6 +228,15 @@
//____________________________________________________________________________//
+template<typename F, typename Arg>
+inline fixture_t
+fixture( Arg const& arg )
+{
+ return fixture_t( test_unit_fixture_ptr( new unit_test::class_based_fixture<F,Arg>( arg ) ) );
+}
+
+//____________________________________________________________________________//
+
inline fixture_t
fixture( boost::function<void()> const& setup, boost::function<void()> const& teardown = boost::function<void()>() )
{
Modified: trunk/boost/test/tree/fixture.hpp
==============================================================================
--- trunk/boost/test/tree/fixture.hpp (original)
+++ trunk/boost/test/tree/fixture.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -48,10 +48,28 @@
// ************** class_based_fixture ************** //
// ************************************************************************** //
-template<typename F>
+template<typename F, typename Arg=void>
class class_based_fixture : public test_unit_fixture {
public:
// Constructor
+ explicit class_based_fixture( Arg const& arg ) : m_inst( 0 ), m_arg( arg ) {}
+
+private:
+ // Fixture interface
+ virtual void setup() { m_inst = new F( m_arg ); }
+ virtual void teardown() { delete m_inst; }
+
+ // Data members
+ F* m_inst;
+ Arg m_arg;
+};
+
+//____________________________________________________________________________//
+
+template<typename F>
+class class_based_fixture<F,void> : public test_unit_fixture {
+public:
+ // Constructor
class_based_fixture() : m_inst( 0 ) {}
private:
@@ -63,6 +81,8 @@
F* m_inst;
};
+//____________________________________________________________________________//
+
// ************************************************************************** //
// ************** function_based_fixture ************** //
// ************************************************************************** //
Modified: trunk/boost/test/unit_test_log.hpp
==============================================================================
--- trunk/boost/test/unit_test_log.hpp (original)
+++ trunk/boost/test/unit_test_log.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -147,7 +147,7 @@
#define BOOST_TEST_MESSAGE( M ) \
BOOST_TEST_LOG_ENTRY( ::boost::unit_test::log_messages ) \
- << (::boost::unit_test::lazy_ostream::instance() << M) \
+ << BOOST_TEST_LAZY_MSG( M ) \
/**/
//____________________________________________________________________________//
Modified: trunk/boost/test/utils/basic_cstring/compare.hpp
==============================================================================
--- trunk/boost/test/utils/basic_cstring/compare.hpp (original)
+++ trunk/boost/test/utils/basic_cstring/compare.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -90,7 +90,7 @@
//____________________________________________________________________________//
// ************************************************************************** //
-// ************** operator < ************** //
+// ************** operators <,> ************** //
// ************************************************************************** //
template<class CharT>
@@ -104,6 +104,38 @@
: traits_type::compare( x.begin(), y.begin(), x.size() ) < 0;
}
+//____________________________________________________________________________//
+
+template<class CharT>
+inline bool
+operator <=( boost::unit_test::basic_cstring<CharT> const& x,
+ boost::unit_test::basic_cstring<CharT> const& y )
+{
+ return !(y < x);
+}
+
+//____________________________________________________________________________//
+
+template<class CharT>
+inline bool
+operator >( boost::unit_test::basic_cstring<CharT> const& x,
+ boost::unit_test::basic_cstring<CharT> const& y )
+{
+ return y < x;
+}
+
+//____________________________________________________________________________//
+
+template<class CharT>
+inline bool
+operator >=( boost::unit_test::basic_cstring<CharT> const& x,
+ boost::unit_test::basic_cstring<CharT> const& y )
+{
+ return !(x < y);
+}
+
+//____________________________________________________________________________//
+
} // namespace unit_test
} // namespace boost
Added: trunk/boost/test/utils/is_cstring.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/utils/is_cstring.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -0,0 +1,55 @@
+// (C) Copyright Gennadiy Rozental 2012.
+// 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$
+//
+// Description : defines the is_forward_iterable collection type trait
+// ***************************************************************************
+
+#ifndef BOOST_TEST_IS_CSTRING_HPP_112512GER
+#define BOOST_TEST_IS_CSTRING_HPP_112512GER
+
+// Boost
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/decay.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+
+//____________________________________________________________________________//
+
+namespace boost {
+namespace unit_test {
+
+// ************************************************************************** //
+// ************** is_cstring ************** //
+// ************************************************************************** //
+
+namespace ut_detail {
+
+template<typename T>
+struct is_cstring_impl : mpl::false_ {};
+
+template<typename T>
+struct is_cstring_impl<T const*> : is_cstring_impl<T*> {};
+
+template<>
+struct is_cstring_impl<char*> : mpl::true_ {};
+
+template<>
+struct is_cstring_impl<wchar_t*> : mpl::true_ {};
+
+} // namespace ut_detail
+
+template<typename T>
+struct is_cstring : ut_detail::is_cstring_impl<typename decay<T>::type> {};
+
+} // namespace unit_test
+} // namespace boost
+
+#endif // BOOST_TEST_IS_CSTRING_HPP_112512GER
Modified: trunk/boost/test/utils/is_forward_iterable.hpp
==============================================================================
--- trunk/boost/test/utils/is_forward_iterable.hpp (original)
+++ trunk/boost/test/utils/is_forward_iterable.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -12,8 +12,8 @@
// Description : defines the is_forward_iterable collection type trait
// ***************************************************************************
-#ifndef BOOST_TEST_IS_FRWARD_ITERABLE_HPP_110612GER
-#define BOOST_TEST_IS_FRWARD_ITERABLE_HPP_110612GER
+#ifndef BOOST_TEST_IS_FORWARD_ITERABLE_HPP_110612GER
+#define BOOST_TEST_IS_FORWARD_ITERABLE_HPP_110612GER
#ifdef BOOST_NO_CXX11_DECLTYPE
// Boost
@@ -74,7 +74,8 @@
is_present<typename T::value_type>::value &&
is_present<decltype(boost::declval<T>().size())>::value &&
is_present<decltype(boost::declval<T>().begin())>::value &&
- !is_same<typename remove_cv<typename T::value_type>::type,char>::value
+ !is_same<typename remove_cv<typename T::value_type>::type,char>::value &&
+ !is_same<typename remove_cv<typename T::value_type>::type,wchar_t>::value
, mpl::true_>::type
test(int);
@@ -95,5 +96,5 @@
} // namespace unit_test
} // namespace boost
-#endif // BOOST_TEST_IS_FRWARD_ITERABLE_HPP_110612GER
+#endif // BOOST_TEST_IS_FORWARD_ITERABLE_HPP_110612GER
Modified: trunk/boost/test/utils/lazy_ostream.hpp
==============================================================================
--- trunk/boost/test/utils/lazy_ostream.hpp (original)
+++ trunk/boost/test/utils/lazy_ostream.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -122,6 +122,8 @@
#endif
+#define BOOST_TEST_LAZY_MSG( M ) (::boost::unit_test::lazy_ostream::instance() << M)
+
} // namespace unit_test
} // namespace boost
Modified: trunk/boost/test/utils/runtime/cla/parameter.hpp
==============================================================================
--- trunk/boost/test/utils/runtime/cla/parameter.hpp (original)
+++ trunk/boost/test/utils/runtime/cla/parameter.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -78,7 +78,7 @@
}
// access methods
- bool has_argument() const { return m_actual_argument!=0; }
+ bool has_argument() const { return m_actual_argument; }
argument const& actual_argument() const { return *m_actual_argument; }
argument_ptr actual_argument() { return m_actual_argument; }
void reset() { m_actual_argument.reset(); }
Modified: trunk/boost/test/utils/runtime/env/variable.hpp
==============================================================================
--- trunk/boost/test/utils/runtime/env/variable.hpp (original)
+++ trunk/boost/test/utils/runtime/env/variable.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -74,7 +74,7 @@
res.reset();
}
- bool has_value() const { return m_data->m_value!=0; }
+ bool has_value() const { return m_data->m_value; }
cstring name() const { return m_data->m_var_name; }
protected:
Modified: trunk/boost/test/utils/runtime/file/config_file_iterator.hpp
==============================================================================
--- trunk/boost/test/utils/runtime/file/config_file_iterator.hpp (original)
+++ trunk/boost/test/utils/runtime/file/config_file_iterator.hpp 2013-02-04 03:32:42 EST (Mon, 04 Feb 2013)
@@ -22,7 +22,6 @@
// Boost.Test
#include <boost/test/utils/iterator/input_iterator_facade.hpp>
-#include <boost/test/utils/callback.hpp>
#include <boost/test/utils/named_params.hpp>
// Boost
@@ -99,7 +98,7 @@
typedef unit_test::input_iterator_facade<config_file_iterator,cstring,cstring> base;
public:
// Public typedefs
- typedef unit_test::callback1<cstring> command_handler;
+ typedef boost::function<cstring ()> command_handler;
// Constructors
config_file_iterator() {}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk