mirror of
https://github.com/boostorg/test.git
synced 2026-01-26 07:02:12 +00:00
Removed deprecated headers/interfaces:
auto_unit_test.hpp
test_exec_monitor.hpp (Test Execution Monitor)
unit_test_framework.hpp
BOOST_BITWISE_EQUAL( L, R )
BOOST_MESSAGE( M )
BOOST_CHECKPOINT( M )
Eliminated callback.hpp in favor of boost::function.
Eliminated need for sero_return_wrapper
Eliminated test_func_with_bound_param in favor of boost::bind
Eliminated auto_tc_exp_fail in favor on new decorator based implementation
Started header reorganization.
introduced subdirectory tools for testing tools related headers
introduced subdirectory tree for test tree management related headers
introduced subdirectory interaction for interaction based testing
test_tools.hpp header split into interface (stay as it was) and implementation places in tools/impl.hpp
Execution monitor: new interface vexecute - to be used to monitor nullary functions with no result values
Introduced notion of auto-registered test unit decorators. General interface and infrastructure put in place. Following decorators already implemented:
decorator::label - adds labels to a test unit
decorator::expected_failures - set expected failures for test unit
decorator::timeout - sets timeout for test unit
decorator::description - sets test unit description
decorator::depends_on - sets test unit dependency
New macro BOOST_TEST_DECORATOR is to be used to specify decorators
Added operator+ and operator += for basic_cstring and std::string
Eliminated some old workarounds
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES deprecated use decorator interface instead
test_case::test_func switched back to readonly property
test_tree_visitor interface extended to facilitate visitors applying the same action to all test units. Added:
virtual bool visit( test_unit const& )
and redirected other interfaces use it as default.
Fixed bug in lazy_ostream_impl construction
[SVN r74640]
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// 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 : deprecated
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER
|
||||
#define BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#endif // BOOST_TEST_AUTO_UNIT_TEST_HPP_071894GER
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2006-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2006-2011.
|
||||
// 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)
|
||||
@@ -17,9 +17,11 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/function/function1.hpp>
|
||||
|
||||
// STL
|
||||
#include <string>
|
||||
|
||||
@@ -56,7 +58,7 @@ struct dbg_startup_info {
|
||||
unit_test::const_string init_done_lock;
|
||||
};
|
||||
|
||||
typedef unit_test::callback1<dbg_startup_info const&> dbg_starter;
|
||||
typedef boost::function<void (dbg_startup_info const&)> dbg_starter;
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** debugger setup ************** //
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2006-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2006-2011.
|
||||
// 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)
|
||||
|
||||
@@ -85,6 +85,12 @@ class type_info;
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 )
|
||||
#define BOOST_TEST_SUPPORT_TOKEN_ITERATOR 1
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK)
|
||||
# define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// (C) Copyright Beman Dawes 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -35,7 +35,6 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/fwd_decl.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/utils/class_properties.hpp>
|
||||
|
||||
// Boost
|
||||
@@ -43,6 +42,7 @@
|
||||
#include <boost/scoped_array.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/cstdlib.hpp>
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
// Constructor
|
||||
translator_holder_base( translator_holder_base_ptr next, const_string tag )
|
||||
: m_next( next )
|
||||
, m_tag( tag.begin(), tag.end() )
|
||||
, m_tag( std::string() + tag )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,7 +112,8 @@ public:
|
||||
|
||||
// translator holder interface
|
||||
// invokes the function F inside the try/catch guarding against specific exception
|
||||
virtual int operator()( unit_test::callback0<int> const& F ) = 0;
|
||||
virtual int operator()( boost::function<int ()> const& F ) = 0;
|
||||
|
||||
// erases specific translator holder from the chain
|
||||
translator_holder_base_ptr erase( translator_holder_base_ptr this_, const_string tag )
|
||||
{
|
||||
@@ -234,7 +235,7 @@ public:
|
||||
// try to detect hardware floating point exceptions (!= 0), and which specific exception to catch
|
||||
unit_test::readwrite_property<unsigned> p_detect_fp_exceptions;
|
||||
|
||||
int execute( unit_test::callback0<int> const& F );
|
||||
int execute( boost::function<int ()> const& F );
|
||||
// Returns: Value returned by function call F().
|
||||
//
|
||||
// Effects: Calls executes supplied function F inside a try/catch block which also may
|
||||
@@ -244,6 +245,9 @@ public:
|
||||
// a hardware or software signal, trap, or other exception.
|
||||
//
|
||||
// Note: execute() doesn't consider it an error for F to return a non-zero value.
|
||||
|
||||
void vexecute( boost::function<void ()> const& F );
|
||||
// Effects: Same as above, but returns nothing
|
||||
|
||||
// register custom (user supplied) exception translator
|
||||
template<typename ExceptionType, typename ExceptionTranslator>
|
||||
@@ -262,7 +266,7 @@ public:
|
||||
|
||||
private:
|
||||
// implementation helpers
|
||||
int catch_signals( unit_test::callback0<int> const& F );
|
||||
int catch_signals( boost::function<int ()> const& F );
|
||||
|
||||
// Data members
|
||||
detail::translator_holder_base_ptr m_custom_translators;
|
||||
@@ -283,7 +287,7 @@ public:
|
||||
: translator_holder_base( next, tag ), m_translator( tr ) {}
|
||||
|
||||
// translator holder interface
|
||||
virtual int operator()( unit_test::callback0<int> const& F )
|
||||
virtual int operator()( boost::function<int ()> const& F )
|
||||
{
|
||||
try {
|
||||
return m_next ? (*m_next)( F ) : F();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <boost/test/detail/fwd_decl.hpp>
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
// STL
|
||||
@@ -105,7 +104,7 @@ BOOST_TEST_DECL void test_unit_aborted( test_unit const& );
|
||||
|
||||
namespace impl { // publisized to facilitate internal unit test only
|
||||
|
||||
void apply_filters( test_unit_id );
|
||||
void apply_filters( test_unit_id );
|
||||
|
||||
} // namespace impl
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ struct cpp_main_caller {
|
||||
, m_argc( argc )
|
||||
, m_argv( argv ) {}
|
||||
|
||||
int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); }
|
||||
int operator()() { return (*m_cpp_main_func)( m_argc, m_argv ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
int (*m_cpp_main_func)( int argc, char* argv[] );
|
||||
int m_argc;
|
||||
char** m_argv;
|
||||
int (*m_cpp_main_func)( int argc, char* argv[] );
|
||||
int m_argc;
|
||||
char** m_argv;
|
||||
};
|
||||
|
||||
} // local namespace
|
||||
@@ -74,8 +74,7 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char
|
||||
|
||||
ex_mon.p_catch_system_errors.value = p != "no";
|
||||
|
||||
result = ex_mon.execute(
|
||||
::boost::unit_test::callback0<int>( cpp_main_caller( cpp_main, argc, argv ) ) );
|
||||
result = ex_mon.execute( cpp_main_caller( cpp_main, argc, argv ) );
|
||||
|
||||
if( result == 0 )
|
||||
result = ::boost::exit_success;
|
||||
|
||||
201
include/boost/test/impl/decorators.ipp
Executable file
201
include/boost/test/impl/decorators.ipp
Executable file
@@ -0,0 +1,201 @@
|
||||
// (C) Copyright Gennadiy Rozental 2011.
|
||||
// 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 : unit test decorators implementation
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_DECORATORS_IPP_091911GER
|
||||
#define BOOST_TEST_DECORATORS_IPP_091911GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tree/decorators.hpp>
|
||||
#include <boost/test/unit_test_suite_impl.hpp>
|
||||
#include <boost/test/framework.hpp>
|
||||
#if BOOST_TEST_SUPPORT_TOKEN_ITERATOR
|
||||
#include <boost/test/utils/iterator/token_iterator.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
namespace decorator {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::collector ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
collector::collector( for_test_unit const& D )
|
||||
{
|
||||
m_tu_decorator.reset( D.clone() );
|
||||
|
||||
if( instance() != NULL ) {
|
||||
for_test_unit_ptr leaf = m_tu_decorator;
|
||||
while( leaf->m_next )
|
||||
leaf = leaf->m_next;
|
||||
|
||||
leaf->m_next = instance()->m_tu_decorator;
|
||||
instance()->m_tu_decorator.reset();
|
||||
}
|
||||
|
||||
instance() = this;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
collector*&
|
||||
collector::instance()
|
||||
{
|
||||
static collector* s_instance = 0;
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
void
|
||||
collector::store_in( test_unit& tu )
|
||||
{
|
||||
tu.p_decorators.value = m_tu_decorator;
|
||||
m_tu_decorator.reset();
|
||||
instance() = 0;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::for_test_unit ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
for_test_unit const&
|
||||
for_test_unit::operator+( for_test_unit const& rhs ) const
|
||||
{
|
||||
rhs.m_next.reset( clone() );
|
||||
|
||||
return rhs;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
void
|
||||
for_test_unit::apply( test_unit& tu )
|
||||
{
|
||||
if( m_next )
|
||||
m_next->apply( tu );
|
||||
do_apply( tu );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
for_test_unit*
|
||||
for_test_unit::clone() const
|
||||
{
|
||||
for_test_unit* res = do_clone();
|
||||
res->m_next = m_next;
|
||||
return res;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::label ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
label::do_apply( test_unit& tu )
|
||||
{
|
||||
tu.add_label( m_label );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::expected_failures ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
expected_failures::do_apply( test_unit& tu )
|
||||
{
|
||||
tu.increase_exp_fail( m_exp_fail );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::timeout ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
timeout::do_apply( test_unit& tu )
|
||||
{
|
||||
tu.p_timeout.value = m_timeout;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::description ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
description::do_apply( test_unit& tu )
|
||||
{
|
||||
tu.p_description.value += m_description;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::depends_on ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
depends_on::do_apply( test_unit& tu )
|
||||
{
|
||||
#if !BOOST_TEST_SUPPORT_TOKEN_ITERATOR
|
||||
throw setup_error( "depends_on decorator is not supported on this platform" );
|
||||
#else
|
||||
string_token_iterator tit( m_dependency, (dropped_delimeters = "/", kept_delimeters = dt_none) );
|
||||
|
||||
test_unit* dep = &framework::master_test_suite();
|
||||
while( tit != string_token_iterator() ) {
|
||||
BOOST_TEST_SETUP_ASSERT( dep->p_type == tut_suite, std::string( "incorrect dependency specification " ) + m_dependency );
|
||||
|
||||
test_unit_id next_id = static_cast<test_suite*>(dep)->get( *tit );
|
||||
|
||||
if( next_id == INV_TEST_UNIT_ID )
|
||||
throw framework::setup_error( std::string( "incorrect dependency specification " ) + m_dependency );
|
||||
|
||||
dep = &framework::get( next_id, tut_any );
|
||||
++tit;
|
||||
}
|
||||
|
||||
tu.depends_on( dep );
|
||||
#endif
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace decorator
|
||||
|
||||
} // namespace unit_test
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_DECORATORS_IPP_091911GER
|
||||
@@ -23,21 +23,21 @@
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/unit_test_parameters.hpp>
|
||||
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/utils/iterator/token_iterator.hpp>
|
||||
|
||||
#include <boost/test/interaction_based.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/test_observer.hpp>
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
#include <boost/test/debug.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
// STL
|
||||
#include <vector>
|
||||
@@ -509,7 +509,7 @@ exception_safety_tester::report_error()
|
||||
// ************************************************************************** //
|
||||
|
||||
void BOOST_TEST_DECL
|
||||
exception_safety( callback0<> const& F, const_string test_name )
|
||||
exception_safety( boost::function<void ()> const& F, const_string test_name )
|
||||
{
|
||||
exception_safety_tester est( test_name );
|
||||
|
||||
|
||||
@@ -791,7 +791,7 @@ static void boost_execution_monitor_attaching_signal_handler( int sig, siginfo_t
|
||||
// ************************************************************************** //
|
||||
|
||||
int
|
||||
execution_monitor::catch_signals( unit_test::callback0<int> const& F )
|
||||
execution_monitor::catch_signals( boost::function<int ()> const& F )
|
||||
{
|
||||
using namespace detail;
|
||||
|
||||
@@ -1071,7 +1071,7 @@ invalid_param_handler( wchar_t const* /* expr */,
|
||||
// ************************************************************************** //
|
||||
|
||||
int
|
||||
execution_monitor::catch_signals( unit_test::callback0<int> const& F )
|
||||
execution_monitor::catch_signals( boost::function<int ()> const& F )
|
||||
{
|
||||
_invalid_parameter_handler old_iph = _invalid_parameter_handler();
|
||||
BOOST_TEST_CRT_HOOK_TYPE old_crt_hook = 0;
|
||||
@@ -1124,7 +1124,7 @@ public:
|
||||
} // namespace detail
|
||||
|
||||
int
|
||||
execution_monitor::catch_signals( unit_test::callback0<int> const& F )
|
||||
execution_monitor::catch_signals( boost::function<int ()> const& F )
|
||||
{
|
||||
return detail::do_invoke( m_custom_translators , F );
|
||||
}
|
||||
@@ -1148,7 +1148,7 @@ execution_monitor::execution_monitor()
|
||||
//____________________________________________________________________________//
|
||||
|
||||
int
|
||||
execution_monitor::execute( unit_test::callback0<int> const& F )
|
||||
execution_monitor::execute( boost::function<int ()> const& F )
|
||||
{
|
||||
if( debug::under_debugger() )
|
||||
p_catch_system_errors.value = false;
|
||||
@@ -1273,6 +1273,20 @@ execution_monitor::execute( unit_test::callback0<int> const& F )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
void
|
||||
execution_monitor::vexecute( boost::function<void ()> const& F )
|
||||
{
|
||||
struct forward {
|
||||
explicit forward( boost::function<void ()> const& F ) : m_F( F ) {}
|
||||
|
||||
int operator()() { m_F(); return 0; }
|
||||
|
||||
boost::function<void ()> const& m_F;
|
||||
};
|
||||
|
||||
execute( forward( F ) );
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** system_error ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
#include <boost/test/unit_test_suite_impl.hpp>
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#include <boost/test/unit_test_monitor.hpp>
|
||||
#include <boost/test/test_observer.hpp>
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
#include <boost/test/results_collector.hpp>
|
||||
#include <boost/test/progress_monitor.hpp>
|
||||
#include <boost/test/results_reporter.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 )
|
||||
#define BOOST_TEST_SUPPORT_RUN_BY_NAME
|
||||
#if BOOST_TEST_SUPPORT_TOKEN_ITERATOR
|
||||
#include <boost/test/utils/iterator/token_iterator.hpp>
|
||||
#endif
|
||||
|
||||
@@ -61,33 +60,13 @@ namespace boost {
|
||||
namespace unit_test {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_start calls wrapper ************** //
|
||||
// ************** test_init call wrapper ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
struct test_start_caller {
|
||||
test_start_caller( test_observer* to, counter_t tc_amount )
|
||||
: m_to( to )
|
||||
, m_tc_amount( tc_amount )
|
||||
{}
|
||||
|
||||
int operator()()
|
||||
{
|
||||
m_to->test_start( m_tc_amount );
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
// Data members
|
||||
test_observer* m_to;
|
||||
counter_t m_tc_amount;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct test_init_caller {
|
||||
explicit test_init_caller( init_unit_test_func init_func )
|
||||
struct test_init_invoker {
|
||||
explicit test_init_invoker( init_unit_test_func init_func )
|
||||
: m_init_func( init_func )
|
||||
{}
|
||||
int operator()()
|
||||
@@ -108,20 +87,6 @@ struct test_init_caller {
|
||||
init_unit_test_func m_init_func;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tu_enabler ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct tu_enabler : public test_tree_visitor {
|
||||
explicit tu_enabler( bool on_off ) : m_on_off( on_off ) {}
|
||||
private:
|
||||
virtual void visit( test_case const& tc ) { tc.p_enabled.value = m_on_off; }
|
||||
virtual bool test_suite_start( test_suite const& ts ) { ts.p_enabled.value = m_on_off; return true; }
|
||||
|
||||
// Data members
|
||||
bool m_on_off;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** name_filter ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -180,7 +145,7 @@ public:
|
||||
// Constructor
|
||||
name_filter( tu_enable_list& tu_to_enable, const_string tc_to_run ) : m_tu_to_enable( tu_to_enable ), m_depth( 0 )
|
||||
{
|
||||
#ifdef BOOST_TEST_SUPPORT_RUN_BY_NAME
|
||||
#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
|
||||
string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) );
|
||||
|
||||
while( tit != string_token_iterator() ) {
|
||||
@@ -246,21 +211,12 @@ public:
|
||||
{}
|
||||
|
||||
private:
|
||||
bool filter_unit( test_unit const& tu )
|
||||
{
|
||||
return tu.has_label( m_label );
|
||||
}
|
||||
|
||||
// test_tree_visitor interface
|
||||
virtual void visit( test_case const& tc )
|
||||
virtual bool visit( test_unit const& tu )
|
||||
{
|
||||
if( filter_unit( tc ) )
|
||||
m_tu_to_enable.push_back( std::make_pair( tc.p_id, false ) ); // found a test case; add it to enable list without children
|
||||
}
|
||||
virtual bool test_suite_start( test_suite const& ts )
|
||||
{
|
||||
if( filter_unit( ts ) ) {
|
||||
m_tu_to_enable.push_back( std::make_pair( ts.p_id, true ) ); // found a test suite; add it to enable list with children and stop recursion
|
||||
if( tu.has_label( m_label ) ) {
|
||||
// found a test unit; add it to list of tu to enable with children and stop recursion in case of suites
|
||||
m_tu_to_enable.push_back( std::make_pair( tu.p_id, tu.p_type == tut_suite ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,29 +224,40 @@ private:
|
||||
}
|
||||
|
||||
// Data members
|
||||
const_string m_label;
|
||||
tu_enable_list& m_tu_to_enable;
|
||||
const_string m_label;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tu_collector ************** //
|
||||
// ************** change_status ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class tu_collector : public test_tree_visitor {
|
||||
class change_status : public test_tree_visitor {
|
||||
public:
|
||||
explicit tu_collector( tu_enable_list& tu_to_enable ) : m_tu_to_enable( tu_to_enable ) {}
|
||||
explicit change_status( bool enable_or_disable ) : m_new_status( enable_or_disable ) {}
|
||||
|
||||
private:
|
||||
// test_tree_visitor interface
|
||||
virtual void visit( test_case const& tc )
|
||||
virtual bool visit( test_unit const& tu ) { tu.p_enabled.value = m_new_status; return true; }
|
||||
|
||||
// Data members
|
||||
bool m_new_status;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** collect_disabled ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class collect_disabled : public test_tree_visitor {
|
||||
public:
|
||||
explicit collect_disabled( tu_enable_list& tu_to_enable ) : m_tu_to_enable( tu_to_enable ) {}
|
||||
|
||||
private:
|
||||
// test_tree_visitor interface
|
||||
virtual bool visit( test_unit const& tu )
|
||||
{
|
||||
if( !tc.p_enabled )
|
||||
m_tu_to_enable.push_back( std::make_pair( tc.p_id, false ) );
|
||||
}
|
||||
virtual bool test_suite_start( test_suite const& ts )
|
||||
{
|
||||
if( !ts.p_enabled )
|
||||
m_tu_to_enable.push_back( std::make_pair( ts.p_id, false ) );
|
||||
if( !tu.p_enabled )
|
||||
m_tu_to_enable.push_back( std::make_pair( tu.p_id, false ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -299,6 +266,22 @@ private:
|
||||
tu_enable_list& m_tu_to_enable;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** apply_decorators ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class apply_decorators : public test_tree_visitor {
|
||||
private:
|
||||
// test_tree_visitor interface
|
||||
virtual bool visit( test_unit const& tu )
|
||||
{
|
||||
if( tu.p_decorators.get() )
|
||||
tu.p_decorators.get()->apply( const_cast<test_unit&>(tu) );
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -360,7 +343,6 @@ public:
|
||||
|
||||
unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 );
|
||||
|
||||
|
||||
// notify all observers about abortion
|
||||
if( unit_test_monitor.is_critical_error( run_result ) ) {
|
||||
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
|
||||
@@ -487,7 +469,7 @@ init( init_unit_test_func init_func, int argc, char* argv[] )
|
||||
try {
|
||||
boost::execution_monitor em;
|
||||
|
||||
ut_detail::test_init_caller tic( init_func );
|
||||
ut_detail::test_init_invoker tic( init_func );
|
||||
|
||||
em.execute( tic );
|
||||
}
|
||||
@@ -495,6 +477,9 @@ init( init_unit_test_func init_func, int argc, char* argv[] )
|
||||
throw setup_error( ex.what() );
|
||||
}
|
||||
|
||||
ut_detail::apply_decorators ad;
|
||||
traverse_test_tree( master_test_suite().p_id, ad, true );
|
||||
|
||||
impl::apply_filters( master_test_suite().p_id );
|
||||
|
||||
s_frk_impl().m_is_initialized = true;
|
||||
@@ -507,14 +492,14 @@ void
|
||||
apply_filters( test_unit_id tu_id )
|
||||
{
|
||||
if( runtime_config::test_to_run().empty() ) {
|
||||
ut_detail::tu_enabler enable( true );
|
||||
|
||||
traverse_test_tree( tu_id, enable );
|
||||
// enable all test units for this run
|
||||
ut_detail::change_status enabler( true );
|
||||
traverse_test_tree( tu_id, enabler, true );
|
||||
}
|
||||
else {
|
||||
// 10. first disable all tu
|
||||
ut_detail::tu_enabler disable( false );
|
||||
traverse_test_tree( tu_id, disable );
|
||||
// 10. First disable all test units. We'll re-enable only those that pass the filters
|
||||
ut_detail::change_status disabler( false );
|
||||
traverse_test_tree( tu_id, disabler, true );
|
||||
|
||||
// 20. collect tu to enable based on filters
|
||||
ut_detail::tu_enable_list tu_to_enable;
|
||||
@@ -568,17 +553,17 @@ apply_filters( test_unit_id tu_id )
|
||||
|
||||
// 35. add all children to the list recursively
|
||||
if( data.second && tu.p_type == tut_suite ) {
|
||||
ut_detail::tu_collector collect( tu_to_enable );
|
||||
traverse_test_tree( tu.p_id, collect, true );
|
||||
ut_detail::collect_disabled V( tu_to_enable );
|
||||
traverse_test_tree( tu.p_id, V, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace impl
|
||||
|
||||
bool
|
||||
is_initialized()
|
||||
{
|
||||
@@ -787,7 +772,7 @@ run( test_unit_id id, bool continue_test )
|
||||
boost::execution_monitor em;
|
||||
|
||||
try {
|
||||
em.execute( ut_detail::test_start_caller( to, tcc.p_count ) );
|
||||
em.vexecute( boost::bind( &test_observer::test_start, to, tcc.p_count ) );
|
||||
}
|
||||
catch( execution_exception const& ex ) {
|
||||
throw setup_error( ex.what() );
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/interaction_based.hpp>
|
||||
#include <boost/test/mock_object.hpp>
|
||||
#include <boost/test/interaction/interaction_based.hpp>
|
||||
#include <boost/test/interaction/mock_object.hpp>
|
||||
#include <boost/test/framework.hpp> // for setup_error
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/utils/iterator/token_iterator.hpp>
|
||||
|
||||
#include <boost/test/interaction_based.hpp>
|
||||
#include <boost/test/interaction/interaction_based.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
// STL
|
||||
#include <fstream>
|
||||
@@ -224,7 +224,7 @@ expectations_logger::return_value( const_string default_value )
|
||||
// ************************************************************************** //
|
||||
|
||||
void BOOST_TEST_DECL
|
||||
logged_expectations( callback0<> const& F, const_string log_file_name, bool test_or_log )
|
||||
logged_expectations( boost::function<void ()> const& F, const_string log_file_name, bool test_or_log )
|
||||
{
|
||||
expectations_logger el( log_file_name, test_or_log );
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#include <boost/test/output_test_stream.hpp>
|
||||
#include <boost/test/tools/output_test_stream.hpp>
|
||||
#include <boost/test/framework.hpp>
|
||||
#include <boost/test/execution_monitor.hpp> // execution_aborted
|
||||
#include <boost/test/unit_test_suite_impl.hpp>
|
||||
|
||||
@@ -32,26 +32,6 @@ namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename F>
|
||||
struct zero_return_wrapper_t {
|
||||
explicit zero_return_wrapper_t( F const& f ) : m_f( f ) {}
|
||||
|
||||
int operator()() { m_f(); return 0; }
|
||||
|
||||
F const& m_f;
|
||||
};
|
||||
|
||||
template<typename F>
|
||||
zero_return_wrapper_t<F>
|
||||
zero_return_wrapper( F const& f )
|
||||
{
|
||||
return zero_return_wrapper_t<F>( f );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test_monitor ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -66,7 +46,7 @@ unit_test_monitor_t::execute_and_translate( test_case const& tc )
|
||||
p_use_alt_stack.value = runtime_config::use_alt_stack();
|
||||
p_detect_fp_exceptions.value = runtime_config::detect_fp_exceptions();
|
||||
|
||||
execute( callback0<int>( zero_return_wrapper( tc.test_func() ) ) );
|
||||
vexecute( tc.p_test_func );
|
||||
}
|
||||
catch( execution_exception const& ex ) {
|
||||
framework::exception_caught( ex );
|
||||
|
||||
@@ -102,7 +102,7 @@ test_unit::increase_exp_fail( unsigned num )
|
||||
void
|
||||
test_unit::add_label( const_string l )
|
||||
{
|
||||
m_labels.push_back( std::string( l.begin(), l.end() ) );
|
||||
m_labels.push_back( std::string() + l );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -119,14 +119,10 @@ test_unit::has_label( const_string l ) const
|
||||
// ************** test_case ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
test_case::test_case( const_string name, callback0<> const& test_func )
|
||||
test_case::test_case( const_string name, boost::function<void ()> const& test_func )
|
||||
: test_unit( name, static_cast<test_unit_type>(type) )
|
||||
, m_test_func( test_func )
|
||||
, p_test_func( test_func )
|
||||
{
|
||||
// !! weirdest MSVC BUG; try to remove this statement; looks like it eats first token of next statement
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
|
||||
0;
|
||||
#endif
|
||||
framework::register_test_unit( this );
|
||||
}
|
||||
|
||||
@@ -155,7 +151,7 @@ test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout )
|
||||
m_members.push_back( tu->p_id );
|
||||
tu->p_parent_id.value = p_id;
|
||||
|
||||
if( tu->p_expected_failures )
|
||||
if( tu->p_expected_failures != 0 )
|
||||
increase_exp_fail( tu->p_expected_failures );
|
||||
|
||||
if( expected_failures )
|
||||
@@ -214,7 +210,7 @@ traverse_test_tree( test_case const& tc, test_tree_visitor& V, bool ignore_statu
|
||||
void
|
||||
traverse_test_tree( test_suite const& suite, test_tree_visitor& V, bool ignore_status )
|
||||
{
|
||||
if( (!suite.p_enabled && !ignore_status) || !V.test_suite_start( suite ) )
|
||||
if( (!ignore_status && !suite.p_enabled) || !V.test_suite_start( suite ) )
|
||||
return;
|
||||
|
||||
try {
|
||||
@@ -252,19 +248,6 @@ traverse_test_tree( test_unit_id id, test_tree_visitor& V, bool ignore_status )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_case_counter ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void
|
||||
test_case_counter::visit( test_case const& tc )
|
||||
{
|
||||
if( tc.p_enabled )
|
||||
++p_count.value;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** object generators ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -285,21 +268,24 @@ normalize_test_case_name( const_string name )
|
||||
// ************** auto_test_unit_registrar ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, counter_t exp_fail )
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail )
|
||||
{
|
||||
curr_ts_store().back()->add( tc, exp_fail );
|
||||
|
||||
if( decorators )
|
||||
decorators->store_in( *tc );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name )
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators )
|
||||
{
|
||||
test_unit_id id = curr_ts_store().back()->get( ts_name );
|
||||
|
||||
test_suite* ts;
|
||||
|
||||
if( id != INV_TEST_UNIT_ID ) {
|
||||
ts = &framework::get<test_suite>( id ); // !! test for invalid tu type
|
||||
ts = &framework::get<test_suite>( id );
|
||||
BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id );
|
||||
}
|
||||
else {
|
||||
@@ -307,14 +293,21 @@ auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name )
|
||||
curr_ts_store().back()->add( ts );
|
||||
}
|
||||
|
||||
if( decorators )
|
||||
decorators->store_in( *ts );
|
||||
|
||||
curr_ts_store().push_back( ts );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen )
|
||||
auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators )
|
||||
{
|
||||
curr_ts_store().back()->add( tc_gen );
|
||||
|
||||
// !! ??if( decorators )
|
||||
// decorators->apply( *tc );
|
||||
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -355,8 +348,6 @@ global_fixture::global_fixture()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_UNIT_TEST_SUITE_IPP_012205GER
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// 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 : included (vs. linked) version of Test Execution Monitor
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
#define BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
|
||||
#include <boost/test/impl/compiler_log_formatter.ipp>
|
||||
#include <boost/test/impl/debug.ipp>
|
||||
#include <boost/test/impl/execution_monitor.ipp>
|
||||
#include <boost/test/impl/framework.ipp>
|
||||
#include <boost/test/impl/plain_report_formatter.ipp>
|
||||
#include <boost/test/impl/progress_monitor.ipp>
|
||||
#include <boost/test/impl/results_collector.ipp>
|
||||
#include <boost/test/impl/results_reporter.ipp>
|
||||
#include <boost/test/impl/test_main.ipp>
|
||||
#include <boost/test/impl/test_tools.ipp>
|
||||
#include <boost/test/impl/unit_test_log.ipp>
|
||||
#include <boost/test/impl/unit_test_main.ipp>
|
||||
#include <boost/test/impl/unit_test_monitor.ipp>
|
||||
#include <boost/test/impl/unit_test_parameters.ipp>
|
||||
#include <boost/test/impl/unit_test_suite.ipp>
|
||||
#include <boost/test/impl/xml_log_formatter.ipp>
|
||||
#include <boost/test/impl/xml_report_formatter.ipp>
|
||||
|
||||
#define BOOST_TEST_INCLUDED
|
||||
#include <boost/test/test_exec_monitor.hpp>
|
||||
|
||||
#endif // BOOST_INCLUDED_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <boost/test/impl/compiler_log_formatter.ipp>
|
||||
#include <boost/test/impl/debug.ipp>
|
||||
#include <boost/test/impl/decorators.ipp>
|
||||
#include <boost/test/impl/framework.ipp>
|
||||
#include <boost/test/impl/exception_safety.ipp>
|
||||
#include <boost/test/impl/execution_monitor.ipp>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
// deprecated
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -18,12 +18,12 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
#include <boost/test/unit_test_suite.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
// STL
|
||||
#include <memory>
|
||||
@@ -53,8 +53,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
|
||||
BOOST_AUTO_TU_REGISTRAR( test_name )( \
|
||||
boost::unit_test::make_test_case( \
|
||||
&BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
|
||||
boost::unit_test::ut_detail::auto_tc_exp_fail< \
|
||||
BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
\
|
||||
void test_name::test_method() \
|
||||
/**/
|
||||
@@ -67,8 +66,7 @@ namespace itest {
|
||||
// ************** exception safety test ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
void BOOST_TEST_DECL exception_safety( unit_test::callback0<> const& F,
|
||||
unit_test::const_string test_name = "" );
|
||||
void BOOST_TEST_DECL exception_safety( boost::function<void ()> const& F, unit_test::const_string test_name = "" );
|
||||
|
||||
} // namespace itest
|
||||
|
||||
@@ -80,7 +78,7 @@ void BOOST_TEST_DECL exception_safety( unit_test::callback0<> const& F,
|
||||
|
||||
#ifndef BOOST_ITEST_NO_NEW_OVERLOADS
|
||||
|
||||
#include <boost/test/interaction_based.hpp>
|
||||
#include <boost/test/interaction/interaction_based.hpp>
|
||||
|
||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::isprint; using ::malloc; using ::free; }
|
||||
@@ -184,8 +182,6 @@ operator delete[]( void* p, std::nothrow_t const& ) throw()
|
||||
|
||||
#endif // BOOST_ITEST_NO_NEW_OVERLOADS
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_EXCEPTION_SAFETY_HPP_111705GER
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -18,7 +18,9 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/unit_test_parameters.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
@@ -46,8 +48,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
|
||||
BOOST_AUTO_TU_REGISTRAR( test_name )( \
|
||||
boost::unit_test::make_test_case( \
|
||||
&BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
|
||||
boost::unit_test::ut_detail::auto_tc_exp_fail< \
|
||||
BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
\
|
||||
void test_name::test_method() \
|
||||
/**/
|
||||
@@ -61,9 +62,7 @@ namespace itest {
|
||||
// ************************************************************************** //
|
||||
|
||||
void BOOST_TEST_DECL
|
||||
logged_expectations( unit_test::callback0<> const& F,
|
||||
unit_test::const_string log_file_name,
|
||||
bool test_or_log = true );
|
||||
logged_expectations( boost::function<void ()> const& F, unit_test::const_string log_file_name, bool test_or_log = true );
|
||||
|
||||
} // namespace itest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/interaction_based.hpp>
|
||||
#include <boost/test/interaction/interaction_based.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/preprocessor/punctuation/comma.hpp>
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2002-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2002-2011.
|
||||
// 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)
|
||||
@@ -118,9 +118,7 @@ int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
|
||||
}
|
||||
catch( boost::execution_exception const& exex ) {
|
||||
if( exex.code() != boost::execution_exception::no_error )
|
||||
BOOST_ERROR( (std::string( "exception \"" ).
|
||||
append( exex.what().begin(), exex.what().end() ).
|
||||
append( "\" caught" ) ).c_str() );
|
||||
BOOST_ERROR( (std::string( "exception \"" ) + exex.what() + "\" caught").c_str() );
|
||||
std::cerr << "\n**** Testing aborted.";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -17,12 +17,14 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/unit_test_suite.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/function/function1.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -44,27 +46,8 @@ namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_func_with_bound_param ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
template<typename ParamType>
|
||||
struct test_func_with_bound_param {
|
||||
template<typename T>
|
||||
test_func_with_bound_param( callback1<ParamType> test_func, T const& param )
|
||||
: m_test_func( test_func )
|
||||
, m_param( param )
|
||||
{}
|
||||
|
||||
void operator()() { m_test_func( m_param ); }
|
||||
|
||||
private:
|
||||
callback1<ParamType> m_test_func;
|
||||
ParamType m_param;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** param_test_case_generator ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -72,10 +55,10 @@ private:
|
||||
template<typename ParamType, typename ParamIter>
|
||||
class param_test_case_generator : public test_unit_generator {
|
||||
public:
|
||||
param_test_case_generator( callback1<ParamType> const& test_func,
|
||||
const_string tc_name,
|
||||
ParamIter par_begin,
|
||||
ParamIter par_end )
|
||||
param_test_case_generator( boost::function<void (ParamType)> const& test_func,
|
||||
const_string tc_name,
|
||||
ParamIter par_begin,
|
||||
ParamIter par_end )
|
||||
: m_test_func( test_func )
|
||||
, m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
|
||||
, m_par_begin( par_begin )
|
||||
@@ -87,8 +70,7 @@ public:
|
||||
if( m_par_begin == m_par_end )
|
||||
return (test_unit*)0;
|
||||
|
||||
test_func_with_bound_param<ParamType> bound_test_func( m_test_func, *m_par_begin );
|
||||
test_unit* res = new test_case( m_tc_name, bound_test_func );
|
||||
test_unit* res = new test_case( m_tc_name, boost::bind( m_test_func, *m_par_begin ) );
|
||||
|
||||
++m_par_begin;
|
||||
|
||||
@@ -97,7 +79,7 @@ public:
|
||||
|
||||
private:
|
||||
// Data members
|
||||
callback1<ParamType> m_test_func;
|
||||
boost::function<void (ParamType)> m_test_func;
|
||||
std::string m_tc_name;
|
||||
mutable ParamIter m_par_begin;
|
||||
ParamIter m_par_end;
|
||||
@@ -126,10 +108,10 @@ struct user_param_tc_method_invoker {
|
||||
|
||||
template<typename ParamType, typename ParamIter>
|
||||
inline ut_detail::param_test_case_generator<ParamType,ParamIter>
|
||||
make_test_case( callback1<ParamType> const& test_func,
|
||||
const_string tc_name,
|
||||
ParamIter par_begin,
|
||||
ParamIter par_end )
|
||||
make_test_case( boost::function<void (ParamType)> const& test_func,
|
||||
const_string tc_name,
|
||||
ParamIter par_begin,
|
||||
ParamIter par_end )
|
||||
{
|
||||
return ut_detail::param_test_case_generator<ParamType,ParamIter>( test_func, tc_name, par_begin, par_end );
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -16,7 +16,7 @@
|
||||
#define BOOST_TEST_PROGRESS_MONITOR_HPP_020105GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/test_observer.hpp>
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
|
||||
// STL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -17,7 +17,7 @@
|
||||
#define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/test_observer.hpp>
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/fwd_decl.hpp>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2003-2010.
|
||||
// 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 : deprecated
|
||||
// ***************************************************************************
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
@@ -1,36 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// 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 : Entry point for the end user into the Test Execution Monitor.
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
#define BOOST_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** Auto Linking ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
// Automatically link to the correct build variant where possible.
|
||||
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TEST_NO_LIB) && \
|
||||
!defined(BOOST_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED)
|
||||
|
||||
# define BOOST_LIB_NAME boost_test_exec_monitor
|
||||
# include <boost/config/auto_link.hpp>
|
||||
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif // BOOST_TEST_EXEC_MONITOR_HPP_071894GER
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -16,7 +16,6 @@
|
||||
#define BOOST_TEST_TEST_TOOLS_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/predicate_result.hpp>
|
||||
#ifndef BOOST_TEST_PROD
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_TEST_STRINGIZE( arg )
|
||||
@@ -24,15 +23,6 @@
|
||||
#define BOOST_TEST_PASSPOINT()
|
||||
#define BOOST_TEST_TOOLS_STRINGIZE( arg ) BOOST_STRINGIZE( arg )
|
||||
#endif
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/workaround.hpp>
|
||||
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
#include <boost/test/utils/lazy_ostream.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
@@ -42,24 +32,6 @@
|
||||
#include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||
#include <boost/preprocessor/arithmetic/add.hpp>
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
|
||||
#include <boost/mpl/or.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <iosfwd>
|
||||
#include <ios> // for std::boolalpha
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -303,50 +275,6 @@ do { \
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ***************************** //
|
||||
// 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 )
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace test_tools {
|
||||
|
||||
typedef unit_test::const_string const_string;
|
||||
|
||||
namespace { bool dummy_cond = false; }
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** print_log_value ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
struct print_log_value {
|
||||
void operator()( std::ostream& ostr, T const& t )
|
||||
{
|
||||
// avoid warning: 'boost::test_tools::<unnamed>::dummy_cond' defined but not used
|
||||
if (::boost::test_tools::dummy_cond) {}
|
||||
|
||||
typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;
|
||||
|
||||
set_precision( ostr, cant_use_nl() );
|
||||
|
||||
ostr << t; // by default print the value
|
||||
}
|
||||
|
||||
void set_precision( std::ostream& ostr, mpl::false_ )
|
||||
{
|
||||
if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
|
||||
ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
|
||||
}
|
||||
|
||||
void set_precision( std::ostream&, mpl::true_ ) {}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
|
||||
namespace boost { namespace test_tools { \
|
||||
template<> \
|
||||
@@ -358,393 +286,7 @@ struct print_log_value<the_type > { \
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#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 );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tools classification ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
enum tool_level {
|
||||
WARN, CHECK, REQUIRE, PASS
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** 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;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** TOOL BOX Implementation ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
BOOST_TEST_DECL
|
||||
bool check_impl( predicate_result const& pr, ::boost::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, ... );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
// 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 \
|
||||
check_impl( 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>
|
||||
predicate_result equal_impl( Left const& left, Right const& right )
|
||||
{
|
||||
return left == right;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right );
|
||||
inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
inline predicate_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 )
|
||||
predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right );
|
||||
inline predicate_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 predicate_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 predicate_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 predicate_result
|
||||
call_impl( Left const& left, Right const& right, mpl::false_ ) const
|
||||
{
|
||||
return equal_impl( left, right );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline predicate_result
|
||||
call_impl( Left const& left, Right const& right, mpl::true_ ) const
|
||||
{
|
||||
return (*this)( right, &left[0] );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline predicate_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>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return !equal_impl_frwd()( left, right );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct lt_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left < right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct le_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left <= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct gt_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left > right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct ge_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left >= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct equal_coll_impl {
|
||||
template <typename Left, typename Right>
|
||||
predicate_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end )
|
||||
{
|
||||
predicate_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>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
predicate_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;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** context_frame ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct BOOST_TEST_DECL context_frame {
|
||||
explicit context_frame( ::boost::unit_test::lazy_ostream const& context_descr );
|
||||
~context_frame();
|
||||
|
||||
operator bool();
|
||||
|
||||
private:
|
||||
int m_frame_id;
|
||||
};
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
} // namespace test_tools
|
||||
|
||||
namespace test_toolbox = test_tools;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//____________________________________________________________________________//
|
||||
#include <boost/test/tools/impl.hpp>
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/predicate_result.hpp>
|
||||
#include <boost/test/tools/predicate_result.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/limits.hpp> // for std::numeric_limits
|
||||
488
include/boost/test/tools/impl.hpp
Executable file
488
include/boost/test/tools/impl.hpp
Executable file
@@ -0,0 +1,488 @@
|
||||
// (C) Copyright Gennadiy Rozental 2011.
|
||||
// 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 of test tools
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER
|
||||
#define BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/tools/predicate_result.hpp>
|
||||
#ifndef BOOST_TEST_PROD
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/test/tools/floating_point_comparison.hpp>
|
||||
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/workaround.hpp>
|
||||
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
#include <boost/test/utils/lazy_ostream.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
|
||||
#include <boost/mpl/or.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
#include <iosfwd>
|
||||
#include <ios> // for std::boolalpha
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** TOOL BOX ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace test_tools {
|
||||
|
||||
typedef unit_test::const_string const_string;
|
||||
|
||||
namespace { bool dummy_cond = false; }
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** print_log_value ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
template<typename T>
|
||||
struct print_log_value {
|
||||
void operator()( std::ostream& ostr, T const& t )
|
||||
{
|
||||
// avoid warning: 'boost::test_tools::<unnamed>::dummy_cond' defined but not used
|
||||
if( ::boost::test_tools::dummy_cond ) {}
|
||||
|
||||
typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;
|
||||
|
||||
set_precision( ostr, cant_use_nl() );
|
||||
|
||||
ostr << t; // by default print the value
|
||||
}
|
||||
|
||||
void set_precision( std::ostream& ostr, mpl::false_ )
|
||||
{
|
||||
if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
|
||||
ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
|
||||
}
|
||||
|
||||
void set_precision( std::ostream&, mpl::true_ ) {}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#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 );
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** tools classification ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
enum tool_level {
|
||||
WARN, CHECK, REQUIRE, PASS
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** 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;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** TOOL BOX Implementation ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
BOOST_TEST_DECL
|
||||
bool check_impl( predicate_result const& pr, ::boost::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, ... );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// 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 \
|
||||
check_impl( 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>
|
||||
predicate_result equal_impl( Left const& left, Right const& right )
|
||||
{
|
||||
return left == right;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
predicate_result BOOST_TEST_DECL equal_impl( char const* left, char const* right );
|
||||
inline predicate_result equal_impl( char* left, char const* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
inline predicate_result equal_impl( char const* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); }
|
||||
inline predicate_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 )
|
||||
predicate_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right );
|
||||
inline predicate_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 predicate_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 predicate_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 predicate_result
|
||||
call_impl( Left const& left, Right const& right, mpl::false_ ) const
|
||||
{
|
||||
return equal_impl( left, right );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline predicate_result
|
||||
call_impl( Left const& left, Right const& right, mpl::true_ ) const
|
||||
{
|
||||
return (*this)( right, &left[0] );
|
||||
}
|
||||
|
||||
template <typename Left, typename Right>
|
||||
inline predicate_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>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return !equal_impl_frwd()( left, right );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct lt_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left < right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct le_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left <= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct gt_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left > right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct ge_impl {
|
||||
template <class Left, class Right>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
return left >= right;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
struct equal_coll_impl {
|
||||
template <typename Left, typename Right>
|
||||
predicate_result operator()( Left left_begin, Left left_end, Right right_begin, Right right_end )
|
||||
{
|
||||
predicate_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>
|
||||
predicate_result operator()( Left const& left, Right const& right )
|
||||
{
|
||||
predicate_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;
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
bool BOOST_TEST_DECL is_defined_impl( const_string symbol_name, const_string symbol_value );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** 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;
|
||||
};
|
||||
|
||||
} // namespace tt_detail
|
||||
|
||||
} // namespace test_tools
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER
|
||||
@@ -18,7 +18,7 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/utils/wrap_stringstream.hpp>
|
||||
#include <boost/test/predicate_result.hpp>
|
||||
#include <boost/test/tools/predicate_result.hpp>
|
||||
|
||||
// STL
|
||||
#include <cstddef> // for std::size_t
|
||||
193
include/boost/test/tree/decorators.hpp
Executable file
193
include/boost/test/tree/decorators.hpp
Executable file
@@ -0,0 +1,193 @@
|
||||
// (C) Copyright Gennadiy Rozental 2011.
|
||||
// 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: 62016 $
|
||||
//
|
||||
// Description : defines decorators to be using with auto registered test units
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_DECORATORS_HPP_091911GER
|
||||
#define BOOST_TEST_DECORATORS_HPP_091911GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
|
||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
class test_unit;
|
||||
|
||||
namespace decorator {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::collector ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class for_test_unit;
|
||||
typedef boost::shared_ptr<for_test_unit> for_test_unit_ptr;
|
||||
|
||||
class BOOST_TEST_DECL collector {
|
||||
public:
|
||||
explicit collector( for_test_unit const& );
|
||||
static collector*& instance();
|
||||
|
||||
void store_in( test_unit& tu );
|
||||
|
||||
private:
|
||||
// Data members
|
||||
for_test_unit_ptr m_tu_decorator;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::for_test_unit ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL for_test_unit {
|
||||
public:
|
||||
virtual ~for_test_unit() {}
|
||||
|
||||
// composition interface 1
|
||||
for_test_unit const& operator+() const { return *this; }
|
||||
for_test_unit const& operator+( for_test_unit const& rhs ) const;
|
||||
|
||||
// composition interface 2
|
||||
for_test_unit const& operator-() const { return *this; }
|
||||
for_test_unit const& operator-( for_test_unit const& rhs ) const { return *this + rhs; }
|
||||
|
||||
// composition interface 3
|
||||
for_test_unit const& operator*() const { return *this; }
|
||||
for_test_unit const& operator*( for_test_unit const& rhs ) const { return *this + rhs; }
|
||||
|
||||
// application interface
|
||||
void apply( test_unit& tu );
|
||||
for_test_unit* clone() const;
|
||||
|
||||
private:
|
||||
friend class collector;
|
||||
|
||||
// decorator::for_test_unit interface
|
||||
virtual for_test_unit* do_clone() const = 0;
|
||||
virtual void do_apply( test_unit& ) = 0;
|
||||
|
||||
// Data members
|
||||
mutable for_test_unit_ptr m_next;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::label ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL label : public decorator::for_test_unit {
|
||||
public:
|
||||
explicit label( const_string l ) : m_label( l ) {}
|
||||
|
||||
private:
|
||||
// decorator::for_test_unit interface
|
||||
virtual void do_apply( test_unit& tu );
|
||||
virtual for_test_unit* do_clone() const { return new label( m_label ); }
|
||||
|
||||
// Data members
|
||||
const_string m_label;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::expected_failures ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL expected_failures : public decorator::for_test_unit {
|
||||
public:
|
||||
explicit expected_failures( counter_t ef ) : m_exp_fail( ef ) {}
|
||||
|
||||
private:
|
||||
// decorator::for_test_unit interface
|
||||
virtual void do_apply( test_unit& tu );
|
||||
virtual for_test_unit* do_clone() const { return new expected_failures( m_exp_fail ); }
|
||||
|
||||
// Data members
|
||||
counter_t m_exp_fail;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::timeout ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL timeout : public decorator::for_test_unit {
|
||||
public:
|
||||
explicit timeout( unsigned t ) : m_timeout( t ) {}
|
||||
|
||||
private:
|
||||
// decorator::for_test_unit interface
|
||||
virtual void do_apply( test_unit& tu );
|
||||
virtual for_test_unit* do_clone() const { return new timeout( m_timeout ); }
|
||||
|
||||
// Data members
|
||||
unsigned m_timeout;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::description ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL description : public decorator::for_test_unit {
|
||||
public:
|
||||
explicit description( const_string descr ) : m_description( descr ) {}
|
||||
|
||||
private:
|
||||
// decorator::for_test_unit interface
|
||||
virtual void do_apply( test_unit& tu );
|
||||
virtual for_test_unit* do_clone() const { return new description( m_description ); }
|
||||
|
||||
// Data members
|
||||
const_string m_description;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** decorator::depends_on ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class BOOST_TEST_DECL depends_on : public decorator::for_test_unit {
|
||||
public:
|
||||
explicit depends_on( const_string dependency ) : m_dependency( dependency ) {}
|
||||
|
||||
private:
|
||||
// decorator::for_test_unit interface
|
||||
virtual void do_apply( test_unit& tu );
|
||||
virtual for_test_unit* do_clone() const { return new depends_on( m_dependency ); }
|
||||
|
||||
// Data members
|
||||
const_string m_dependency;
|
||||
};
|
||||
|
||||
} // namespace decorator
|
||||
|
||||
using decorator::label;
|
||||
using decorator::expected_failures;
|
||||
using decorator::timeout;
|
||||
using decorator::description;
|
||||
using decorator::depends_on;
|
||||
|
||||
} // unit_test
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_DECORATORS_HPP_091911GER
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2005-2011.
|
||||
// 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)
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -18,7 +18,7 @@
|
||||
#define BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/test_observer.hpp>
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/detail/log_level.hpp>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2003-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2003-2011.
|
||||
// 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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <boost/test/execution_monitor.hpp>
|
||||
#include <boost/test/detail/fwd_decl.hpp>
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -26,7 +26,7 @@
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_CASE( test_function ) \
|
||||
boost::unit_test::make_test_case( boost::unit_test::callback0<>(test_function), BOOST_TEST_STRINGIZE( test_function ) )
|
||||
boost::unit_test::make_test_case( boost::function<void ()>(test_function), BOOST_TEST_STRINGIZE( test_function ) )
|
||||
#define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \
|
||||
boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance )
|
||||
|
||||
@@ -43,7 +43,9 @@ boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_fun
|
||||
|
||||
#define BOOST_AUTO_TEST_SUITE( suite_name ) \
|
||||
namespace suite_name { \
|
||||
BOOST_AUTO_TU_REGISTRAR( suite_name )( BOOST_STRINGIZE( suite_name ) ); \
|
||||
BOOST_AUTO_TU_REGISTRAR( suite_name )( \
|
||||
BOOST_STRINGIZE( suite_name ), \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -67,20 +69,10 @@ BOOST_AUTO_TU_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** //
|
||||
// ************************************************************************** //
|
||||
// deprecated; use decorator instead
|
||||
|
||||
#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \
|
||||
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ); \
|
||||
\
|
||||
static struct BOOST_JOIN( test_name, _exp_fail_num_spec ) \
|
||||
: boost::unit_test::ut_detail:: \
|
||||
auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) > \
|
||||
{ \
|
||||
BOOST_JOIN( test_name, _exp_fail_num_spec )() \
|
||||
: boost::unit_test::ut_detail:: \
|
||||
auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) >( n ) \
|
||||
{} \
|
||||
} BOOST_JOIN( test_name, _exp_fail_num_spec_inst ); \
|
||||
\
|
||||
BOOST_TEST_DECORATOR( boost::unit_test::expected_failures( n ) )
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -101,8 +93,7 @@ struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
|
||||
BOOST_AUTO_TU_REGISTRAR( test_name )( \
|
||||
boost::unit_test::make_test_case( \
|
||||
&BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
|
||||
boost::unit_test::ut_detail::auto_tc_exp_fail< \
|
||||
BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
\
|
||||
void test_name::test_method() \
|
||||
/**/
|
||||
@@ -136,7 +127,8 @@ struct BOOST_AUTO_TC_INVOKER( test_name ) { \
|
||||
BOOST_AUTO_TU_REGISTRAR( test_name )( \
|
||||
boost::unit_test::ut_detail::template_test_case_gen< \
|
||||
BOOST_AUTO_TC_INVOKER( test_name ),TL >( \
|
||||
BOOST_STRINGIZE( test_name ) ) ); \
|
||||
BOOST_STRINGIZE( test_name ) ), \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
\
|
||||
template<typename type_name> \
|
||||
void test_name<type_name>::test_method() \
|
||||
@@ -153,29 +145,29 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( test_name, type_name, TL, BOOST_AUTO_TEST_CASE
|
||||
// ************** BOOST_TEST_CASE_TEMPLATE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \
|
||||
boost::unit_test::ut_detail::template_test_case_gen<name,typelist >( \
|
||||
BOOST_TEST_STRINGIZE( name ) ) \
|
||||
#define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \
|
||||
boost::unit_test::ut_detail::template_test_case_gen<name,typelist >(\
|
||||
BOOST_TEST_STRINGIZE( name ) ) \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_CASE_TEMPLATE_FUNCTION ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \
|
||||
template<typename type_name> \
|
||||
void BOOST_JOIN( name, _impl )( boost::type<type_name>* ); \
|
||||
\
|
||||
struct name { \
|
||||
template<typename TestType> \
|
||||
static void run( boost::type<TestType>* frwrd = 0 ) \
|
||||
{ \
|
||||
BOOST_JOIN( name, _impl )( frwrd ); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template<typename type_name> \
|
||||
void BOOST_JOIN( name, _impl )( boost::type<type_name>* ) \
|
||||
#define BOOST_TEST_CASE_TEMPLATE_FUNCTION( name, type_name ) \
|
||||
template<typename type_name> \
|
||||
void BOOST_JOIN( name, _impl )( boost::type<type_name>* ); \
|
||||
\
|
||||
struct name { \
|
||||
template<typename TestType> \
|
||||
static void run( boost::type<TestType>* frwrd = 0 ) \
|
||||
{ \
|
||||
BOOST_JOIN( name, _impl )( frwrd ); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template<typename type_name> \
|
||||
void BOOST_JOIN( name, _impl )( boost::type<type_name>* ) \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -186,6 +178,15 @@ void BOOST_JOIN( name, _impl )( boost::type<type_name>* ) \
|
||||
static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) ; \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_DECORATOR ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_DECORATOR( D ) \
|
||||
static boost::unit_test::decorator::collector \
|
||||
BOOST_JOIN(decorator_collector,__LINE__)( D ); \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001-2010.
|
||||
// (C) Copyright Gennadiy Rozental 2001-2011.
|
||||
// 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)
|
||||
@@ -18,11 +18,13 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/detail/config.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
#include <boost/test/utils/class_properties.hpp>
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
#include <boost/test/detail/fwd_decl.hpp>
|
||||
#include <boost/test/detail/workaround.hpp>
|
||||
#include <boost/test/test_observer.hpp>
|
||||
|
||||
#include <boost/test/utils/class_properties.hpp>
|
||||
|
||||
#include <boost/test/tree/observer.hpp>
|
||||
#include <boost/test/tree/decorators.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@@ -30,6 +32,7 @@
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/function/function0.hpp>
|
||||
|
||||
// STL
|
||||
#include <typeinfo> // for typeid
|
||||
@@ -45,6 +48,13 @@ namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_unit_fixture ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct test_unit_fixture {
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_unit ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -78,9 +88,12 @@ public:
|
||||
|
||||
// Public r/w properties
|
||||
readwrite_property<std::string> p_name; // name for this test unit
|
||||
readwrite_property<std::string> p_description; // description for this test unit
|
||||
readwrite_property<unsigned> p_timeout; // timeout for the test unit execution
|
||||
readwrite_property<counter_t> p_expected_failures; // number of expected failures in this test unit
|
||||
mutable readwrite_property<bool> p_enabled; // enabled status for this unit
|
||||
mutable readwrite_property<bool> p_enabled; // enabled/disabled status for this unit
|
||||
|
||||
readwrite_property<decorator::for_test_unit_ptr> p_decorators; // automatically assigned decorators; execution is delayed till framework::init function
|
||||
|
||||
void increase_exp_fail( unsigned num );
|
||||
|
||||
@@ -90,6 +103,7 @@ protected:
|
||||
private:
|
||||
// Data members
|
||||
std::list<std::string> m_labels;
|
||||
decorator::for_test_unit_ptr m_decorators;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -113,18 +127,16 @@ public:
|
||||
enum { type = tut_case };
|
||||
|
||||
// Constructor
|
||||
test_case( const_string tc_name, callback0<> const& test_func );
|
||||
test_case( const_string tc_name, boost::function<void ()> const& test_func );
|
||||
|
||||
// Access methods
|
||||
callback0<> const& test_func() const { return m_test_func; }
|
||||
// Public property
|
||||
typedef BOOST_READONLY_PROPERTY(boost::function<void ()>,(test_case)) test_func;
|
||||
|
||||
test_func p_test_func;
|
||||
|
||||
private:
|
||||
friend class framework_impl;
|
||||
~test_case() {}
|
||||
|
||||
// BOOST_MSVC <= 1200 have problems with callback as property
|
||||
// Data members
|
||||
callback0<> m_test_func;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -181,8 +193,9 @@ public:
|
||||
class BOOST_TEST_DECL test_tree_visitor {
|
||||
public:
|
||||
// test tree visitor interface
|
||||
virtual void visit( test_case const& ) {}
|
||||
virtual bool test_suite_start( test_suite const& ) { return true; }
|
||||
virtual bool visit( test_unit const& ) { return true; }
|
||||
virtual void visit( test_case const& tc ) { visit( (test_unit const&)tc ); }
|
||||
virtual bool test_suite_start(test_suite const& ts) { return visit( (test_unit const&)ts ); }
|
||||
virtual void test_suite_finish( test_suite const& ) {}
|
||||
|
||||
protected:
|
||||
@@ -222,18 +235,18 @@ public:
|
||||
BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count;
|
||||
private:
|
||||
// test tree visitor interface
|
||||
virtual void visit( test_case const& );
|
||||
virtual void visit( test_case const& tc ) { if( tc.p_enabled ) ++p_count.value; }
|
||||
virtual bool test_suite_start( test_suite const& ts ) { return ts.p_enabled; }
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** test_being_aborted ************** //
|
||||
// ************** test_being_aborted ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
struct BOOST_TEST_DECL test_being_aborted {};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** object generators ************** //
|
||||
// ************** user_tc_method_invoker ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
@@ -257,8 +270,12 @@ struct user_tc_method_invoker {
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** make_test_case ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
inline test_case*
|
||||
make_test_case( callback0<> const& test_func, const_string tc_name )
|
||||
make_test_case( boost::function<void ()> const& test_func, const_string tc_name )
|
||||
{
|
||||
return new test_case( ut_detail::normalize_test_case_name( tc_name ), test_func );
|
||||
}
|
||||
@@ -286,9 +303,9 @@ namespace ut_detail {
|
||||
struct BOOST_TEST_DECL auto_test_unit_registrar
|
||||
{
|
||||
// Constructors
|
||||
auto_test_unit_registrar( test_case* tc, counter_t exp_fail );
|
||||
explicit auto_test_unit_registrar( const_string ts_name );
|
||||
explicit auto_test_unit_registrar( test_unit_generator const& tc_gen );
|
||||
auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail = 0 );
|
||||
explicit auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators );
|
||||
explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators );
|
||||
explicit auto_test_unit_registrar( int );
|
||||
|
||||
private:
|
||||
@@ -297,33 +314,6 @@ private:
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
struct auto_tc_exp_fail {
|
||||
auto_tc_exp_fail() : m_value( 0 ) {}
|
||||
|
||||
explicit auto_tc_exp_fail( unsigned v )
|
||||
: m_value( v )
|
||||
{
|
||||
instance() = this;
|
||||
}
|
||||
|
||||
static auto_tc_exp_fail*& instance()
|
||||
{
|
||||
static auto_tc_exp_fail inst;
|
||||
static auto_tc_exp_fail* inst_ptr = &inst;
|
||||
|
||||
return inst_ptr;
|
||||
}
|
||||
|
||||
unsigned value() const { return m_value; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
unsigned m_value;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
|
||||
@@ -720,6 +720,28 @@ assign_op( std::basic_string<CharT1>& target, basic_cstring<CharT2> src, int )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename CharT1, typename CharT2>
|
||||
inline std::basic_string<CharT1>&
|
||||
operator+=( std::basic_string<CharT1>& target, basic_cstring<CharT2> const& str )
|
||||
{
|
||||
target.append( str.begin(), str.end() );
|
||||
return target;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename CharT1, typename CharT2>
|
||||
inline std::basic_string<CharT1>
|
||||
operator+( std::basic_string<CharT1> const& lhs, basic_cstring<CharT2> const& rhs )
|
||||
{
|
||||
std::basic_string<CharT1> res( lhs );
|
||||
|
||||
res.append( rhs.begin(), rhs.end() );
|
||||
return res;
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace unit_test
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2005-2010.
|
||||
// Use, modification, and distribution are subject to 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 :
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_CALLBACK_020505GER
|
||||
#define BOOST_TEST_CALLBACK_020505GER
|
||||
|
||||
// Boost
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(BOOST_INTEL, <= 700)
|
||||
# define BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace unit_test {
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
struct unused {};
|
||||
|
||||
template<typename R>
|
||||
struct invoker {
|
||||
template<typename Functor>
|
||||
R invoke( Functor& f ) { return f(); }
|
||||
template<typename Functor, typename T1>
|
||||
R invoke( Functor& f, T1 t1 ) { return f( t1 ); }
|
||||
template<typename Functor, typename T1, typename T2>
|
||||
R invoke( Functor& f, T1 t1, T2 t2 ) { return f( t1, t2 ); }
|
||||
template<typename Functor, typename T1, typename T2, typename T3>
|
||||
R invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { return f( t1, t2, t3 ); }
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<>
|
||||
struct invoker<unused> {
|
||||
template<typename Functor>
|
||||
unused invoke( Functor& f ) { f(); return unused(); }
|
||||
template<typename Functor, typename T1>
|
||||
unused invoke( Functor& f, T1 t1 ) { f( t1 ); return unused(); }
|
||||
template<typename Functor, typename T1, typename T2>
|
||||
unused invoke( Functor& f, T1 t1, T2 t2 ) { f( t1, t2 ); return unused(); }
|
||||
template<typename Functor, typename T1, typename T2, typename T3>
|
||||
unused invoke( Functor& f, T1 t1, T2 t2, T3 t3 ) { f( t1, t2, t3 ); return unused(); }
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test::callback0 ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
template<typename R>
|
||||
struct callback0_impl {
|
||||
virtual ~callback0_impl() {}
|
||||
|
||||
virtual R invoke() = 0;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename R, typename Functor>
|
||||
struct callback0_impl_t : callback0_impl<R> {
|
||||
// Constructor
|
||||
explicit callback0_impl_t( Functor f ) : m_f( f ) {}
|
||||
|
||||
virtual R invoke() { return invoker<R>().invoke( m_f ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
Functor m_f;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
template<typename R = ut_detail::unused>
|
||||
class callback0 {
|
||||
public:
|
||||
// Constructors
|
||||
callback0() {}
|
||||
#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
callback0( callback0 const& rhs ) : m_impl( rhs.m_impl ) {}
|
||||
#endif
|
||||
|
||||
template<typename Functor>
|
||||
callback0( Functor f )
|
||||
: m_impl( new ut_detail::callback0_impl_t<R,Functor>( f ) ) {}
|
||||
|
||||
void operator=( callback0 const& rhs ) { m_impl = rhs.m_impl; }
|
||||
|
||||
template<typename Functor>
|
||||
void operator=( Functor f ) { m_impl.reset( new ut_detail::callback0_impl_t<R,Functor>( f ) ); }
|
||||
|
||||
R operator()() const { return m_impl->invoke(); }
|
||||
|
||||
bool operator!() const { return !m_impl; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
boost::shared_ptr<ut_detail::callback0_impl<R> > m_impl;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test::callback1 ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
template<typename R, typename T1>
|
||||
struct callback1_impl {
|
||||
virtual ~callback1_impl() {}
|
||||
|
||||
virtual R invoke( T1 t1 ) = 0;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename R, typename T1,typename Functor>
|
||||
struct callback1_impl_t : callback1_impl<R,T1> {
|
||||
// Constructor
|
||||
explicit callback1_impl_t( Functor f ) : m_f( f ) {}
|
||||
|
||||
virtual R invoke( T1 t1 ) { return invoker<R>().invoke( m_f, t1 ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
Functor m_f;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
template<typename T1,typename R = ut_detail::unused>
|
||||
class callback1 {
|
||||
public:
|
||||
// Constructors
|
||||
callback1() {}
|
||||
#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
callback1( callback1 const& rhs ) : m_impl( rhs.m_impl ) {}
|
||||
#endif
|
||||
|
||||
template<typename Functor>
|
||||
callback1( Functor f )
|
||||
: m_impl( new ut_detail::callback1_impl_t<R,T1,Functor>( f ) ) {}
|
||||
|
||||
void operator=( callback1 const& rhs ) { m_impl = rhs.m_impl; }
|
||||
|
||||
template<typename Functor>
|
||||
void operator=( Functor f ) { m_impl.reset( new ut_detail::callback1_impl_t<R,T1,Functor>( f ) ); }
|
||||
|
||||
R operator()( T1 t1 ) const { return m_impl->invoke( t1 ); }
|
||||
|
||||
bool operator!() const { return !m_impl; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
boost::shared_ptr<ut_detail::callback1_impl<R,T1> > m_impl;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test::callback2 ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
template<typename R, typename T1,typename T2>
|
||||
struct callback2_impl {
|
||||
virtual ~callback2_impl() {}
|
||||
|
||||
virtual R invoke( T1 t1, T2 t2 ) = 0;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename R, typename T1, typename T2, typename Functor>
|
||||
struct callback2_impl_t : callback2_impl<R,T1,T2> {
|
||||
// Constructor
|
||||
explicit callback2_impl_t( Functor f ) : m_f( f ) {}
|
||||
|
||||
virtual R invoke( T1 t1, T2 t2 ) { return invoker<R>().template invoke<Functor,T1,T2>( m_f, t1, t2 ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
Functor m_f;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
template<typename T1,typename T2, typename R = ut_detail::unused>
|
||||
class callback2 {
|
||||
public:
|
||||
// Constructors
|
||||
callback2() {}
|
||||
#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
callback2( callback2 const& rhs ) : m_impl( rhs.m_impl ) {}
|
||||
#endif
|
||||
|
||||
template<typename Functor>
|
||||
callback2( Functor f ) : m_impl( new ut_detail::callback2_impl_t<R,T1,T2,Functor>( f ) ) {}
|
||||
|
||||
void operator=( callback2 const& rhs ) { m_impl = rhs.m_impl; }
|
||||
|
||||
template<typename Functor>
|
||||
void operator=( Functor f ) { m_impl.reset( new ut_detail::callback2_impl_t<R,T1,T2,Functor>( f ) ); }
|
||||
|
||||
R operator()( T1 t1, T2 t2 ) const { return m_impl->invoke( t1, t2 ); }
|
||||
|
||||
bool operator!() const { return !m_impl; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
boost::shared_ptr<ut_detail::callback2_impl<R,T1,T2> > m_impl;
|
||||
};
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** unit_test::callback3 ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace ut_detail {
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3>
|
||||
struct callback3_impl {
|
||||
virtual ~callback3_impl() {}
|
||||
|
||||
virtual R invoke( T1 t1, T2 t2, T3 t3 ) = 0;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename R, typename T1, typename T2, typename T3, typename Functor>
|
||||
struct callback3_impl_t : callback3_impl<R,T1,T2,T3> {
|
||||
// Constructor
|
||||
explicit callback3_impl_t( Functor f ) : m_f( f ) {}
|
||||
|
||||
virtual R invoke( T1 t1, T2 t2, T3 t3 ) { return invoker<R>().invoke( m_f, t1, t2, t3 ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
Functor m_f;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace ut_detail
|
||||
|
||||
template<typename T1,typename T2, typename T3, typename R = ut_detail::unused>
|
||||
class callback3 {
|
||||
public:
|
||||
// Constructors
|
||||
callback3() {}
|
||||
#ifdef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
callback3( callback3 const& rhs ) : m_impl( rhs.m_impl ) {}
|
||||
#endif
|
||||
|
||||
template<typename Functor>
|
||||
callback3( Functor f )
|
||||
: m_impl( new ut_detail::callback3_impl_t<R,T1,T2,T3,Functor>( f ) ) {}
|
||||
|
||||
void operator=( callback3 const& rhs ) { m_impl = rhs.m_impl; }
|
||||
|
||||
template<typename Functor>
|
||||
void operator=( Functor f ) { m_impl.reset( new ut_detail::callback3_impl_t<R,T1,T2,T3,Functor>( f ) ); }
|
||||
|
||||
R operator()( T1 t1, T2 t2, T3 t3 ) const { return m_impl->invoke( t1, t2, t3 ); }
|
||||
|
||||
bool operator!() const { return !m_impl; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
boost::shared_ptr<ut_detail::callback3_impl<R,T1,T2,T3> > m_impl;
|
||||
};
|
||||
|
||||
} // namespace unit_test
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_CALLBACK_EXPLICIT_COPY_CONSTRUCTOR
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_CALLBACK_020505GER
|
||||
@@ -79,10 +79,10 @@ private:
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename T>
|
||||
inline lazy_ostream_impl<lazy_ostream,T>
|
||||
inline lazy_ostream_impl<lazy_ostream const&,T>
|
||||
operator<<( lazy_ostream const& prev, T const& v )
|
||||
{
|
||||
return lazy_ostream_impl<lazy_ostream,T>( prev, v );
|
||||
return lazy_ostream_impl<lazy_ostream const&,T>( prev, v );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -103,7 +103,9 @@ template<typename PrevPrevType, typename TPrev,typename R,typename S>
|
||||
inline lazy_ostream_impl<lazy_ostream_impl<PrevPrevType,TPrev>,R& (BOOST_TEST_CALL_DECL *)(S&)>
|
||||
operator<<( lazy_ostream_impl<PrevPrevType,TPrev> const& prev, R& (BOOST_TEST_CALL_DECL *man)(S&) )
|
||||
{
|
||||
return lazy_ostream_impl<lazy_ostream_impl<PrevPrevType,TPrev>,R& (BOOST_TEST_CALL_DECL *)(S&)>( prev, man );
|
||||
typedef R& (BOOST_TEST_CALL_DECL * ManipType)(S&);
|
||||
|
||||
return lazy_ostream_impl<lazy_ostream_impl<PrevPrevType,TPrev>,ManipType>( prev, man );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -33,11 +33,9 @@
|
||||
|
||||
#include <boost/test/utils/runtime/cla/iface/argument_factory.hpp>
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/function/function2.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -112,9 +110,9 @@ struct typed_argument_factory : public argument_factory {
|
||||
|
||||
// !! private?
|
||||
// Data members
|
||||
unit_test::callback2<parameter const&,T&> m_value_handler;
|
||||
unit_test::callback2<parser const&,boost::optional<T>&> m_value_generator;
|
||||
unit_test::callback2<argv_traverser&,boost::optional<T>&> m_value_interpreter;
|
||||
boost::function<void (parameter const&,T&)> m_value_handler;
|
||||
boost::function<void (parser const&,boost::optional<T>&)> m_value_generator;
|
||||
boost::function<void (argv_traverser&,boost::optional<T>&)> m_value_interpreter;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
#include <boost/test/utils/runtime/env/modifier.hpp>
|
||||
#include <boost/test/utils/runtime/env/variable.hpp>
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/callback.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user