diff --git a/build/Jamfile.v2 b/build/Jamfile.v2
index 44016cd0..3653cd59 100644
--- a/build/Jamfile.v2
+++ b/build/Jamfile.v2
@@ -9,11 +9,13 @@ project boost/test
: requirements shared:BOOST_TEST_DYN_LINK=1
msvc:on
borland:-w-8080
- # Disable Warning about boost::noncopyable not being exported
- shared,msvc:-wd4275
+ # Disable Warning about boost::noncopyable not being exported
+ shared,msvc:-wd4275
+ msvc:-wd4671
+ msvc:-wd4673
+ all
: usage-requirements
BOOST_TEST_NO_AUTO_LINK=1
- shared:BOOST_TEST_DYN_LINK=1
# Disable Warning about boost::noncopyable not being exported
shared,msvc:-wd4275
;
@@ -66,12 +68,33 @@ UTF_SOURCES =
xml_report_formatter
;
-lib boost_prg_exec_monitor : $(PRG_EXEC_MON_SOURCES).cpp ;
+lib boost_prg_exec_monitor
+ : # sources
+ $(PRG_EXEC_MON_SOURCES).cpp
+ : # requirements
+ : # default build
+ : # usage-requirements
+ shared:BOOST_TEST_DYN_LINK=1
+ ;
-lib boost_test_exec_monitor : $(TEST_EXEC_MON_SOURCES).cpp : static ;
+lib boost_test_exec_monitor
+ : # sources
+ $(TEST_EXEC_MON_SOURCES).cpp
+ : # requirements
+ static
+ : # default build
+ : # usage-requirements
+ shared:BOOST_TEST_DYN_LINK=1
+ ;
-lib boost_unit_test_framework : $(UTF_SOURCES).cpp ;
-
+lib boost_unit_test_framework
+ : # sources
+ $(UTF_SOURCES).cpp
+ : # requirements
+ : # default build
+ : # usage-requirements
+ shared:BOOST_TEST_DYN_LINK=1
+ ;
alias minimal : : : :
msvc:on
@@ -81,8 +104,7 @@ alias included : : : :
msvc:on
;
-
boost-install boost_prg_exec_monitor
boost_test_exec_monitor
- boost_unit_test_framework ;
-
\ No newline at end of file
+ boost_unit_test_framework ;
+
\ No newline at end of file
diff --git a/example/Jamfile.v2 b/example/Jamfile.v2
index fee059b2..de45b02a 100644
--- a/example/Jamfile.v2
+++ b/example/Jamfile.v2
@@ -59,4 +59,8 @@ test-suite boost_test_examples
[ run named_param_example.cpp ]
[ run const_string_test.cpp ]
+
+ [ run-fail external_main_example_1.cpp unit_test_framework ]
+ [ run-fail external_main_example_2.cpp unit_test_framework ]
+ [ run-fail external_main_example_3.cpp ]
;
diff --git a/example/external_main_example_1.cpp b/example/external_main_example_1.cpp
new file mode 100644
index 00000000..8792ed59
--- /dev/null
+++ b/example/external_main_example_1.cpp
@@ -0,0 +1,43 @@
+#ifndef BOOST_TEST_DYN_LINK
+#define BOOST_TEST_DYN_LINK
+#endif
+#include
+#include
+using namespace boost::unit_test;
+
+//____________________________________________________________________________//
+
+void free_test_function( int i, int j )
+{
+ BOOST_CHECK_EQUAL( i, j );
+}
+
+//____________________________________________________________________________//
+
+bool
+init_function()
+{
+ framework::master_test_suite().
+ add( BOOST_TEST_CASE( boost::bind( &free_test_function, 1, 1 ) ) );
+ framework::master_test_suite().
+ add( BOOST_TEST_CASE( boost::bind( &free_test_function, 1, 2 ) ) );
+ framework::master_test_suite().
+ add( BOOST_TEST_CASE( boost::bind( &free_test_function, 2, 1 ) ) );
+
+ // do your own initialization here
+ // if it successful return true
+
+ // But, you CAN'T use testing tools here
+
+ return true;
+}
+
+//____________________________________________________________________________//
+
+int
+main( int argc, char* argv[] )
+{
+ return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
+}
+
+//____________________________________________________________________________//
diff --git a/example/external_main_example_2.cpp b/example/external_main_example_2.cpp
new file mode 100644
index 00000000..d3fd7f3e
--- /dev/null
+++ b/example/external_main_example_2.cpp
@@ -0,0 +1,40 @@
+#ifndef BOOST_TEST_DYN_LINK
+#define BOOST_TEST_DYN_LINK
+#endif
+#include
+using namespace boost::unit_test;
+
+//____________________________________________________________________________//
+
+BOOST_AUTO_TEST_SUITE( test_suite_1 )
+
+BOOST_AUTO_TEST_CASE( test_case_1 )
+{
+ BOOST_MESSAGE( "Testing is in progress" );
+
+ BOOST_CHECK( false );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+//____________________________________________________________________________//
+
+bool
+init_function()
+{
+ // do your own initialization here
+ // if it successful return true
+
+ // But, you CAN'T use testing tools here
+ return true;
+}
+
+//____________________________________________________________________________//
+
+int
+main( int argc, char* argv[] )
+{
+ return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
+}
+
+//____________________________________________________________________________//
diff --git a/example/external_main_example_3.cpp b/example/external_main_example_3.cpp
new file mode 100644
index 00000000..65948787
--- /dev/null
+++ b/example/external_main_example_3.cpp
@@ -0,0 +1,40 @@
+#define BOOST_TEST_NO_MAIN
+#define BOOST_TEST_ALTERNATIVE_INIT_API
+#include
+using namespace boost::unit_test;
+
+//____________________________________________________________________________//
+
+BOOST_AUTO_TEST_SUITE( test_suite_1 )
+
+BOOST_AUTO_TEST_CASE( test_case_1 )
+{
+ BOOST_MESSAGE( "Testing is in progress" );
+
+ BOOST_CHECK( false );
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+//____________________________________________________________________________//
+
+bool
+init_function()
+{
+ // do your own initialization here
+ // if it successful return true
+
+ // But, you CAN'T use testing tools here
+ return true;
+}
+
+//____________________________________________________________________________//
+
+int
+main( int argc, char* argv[] )
+{
+ return ::boost::unit_test::unit_test_main( &init_function, argc, argv );
+}
+
+//____________________________________________________________________________//
+
diff --git a/example/test_case_template_example.cpp b/example/test_case_template_example.cpp
index 51351351..66fcc8fd 100644
--- a/example/test_case_template_example.cpp
+++ b/example/test_case_template_example.cpp
@@ -10,8 +10,7 @@
# pragma warning(disable: C4345)
#endif
-#include
-#include
+#include
using boost::unit_test::test_suite;
// Boost.MPL
diff --git a/include/boost/test/detail/enable_warnings.hpp b/include/boost/test/detail/enable_warnings.hpp
index 94bc6c80..7c11ba23 100644
--- a/include/boost/test/detail/enable_warnings.hpp
+++ b/include/boost/test/detail/enable_warnings.hpp
@@ -13,8 +13,8 @@
// ***************************************************************************
#ifdef BOOST_MSVC
-# pragma warning(default: 4511) // copy constructor could not be generated
-# pragma warning(default: 4512) // assignment operator could not be generated
+# pragma warning(default: 4511) // copy constructor can't not be generated
+# pragma warning(default: 4512) // assignment operator can't not be generated
# pragma warning(default: 4100) // unreferenced formal parameter
# pragma warning(default: 4996) // was declared deprecated
# pragma warning(default: 4355) // 'this' : used in base member initializer list
@@ -24,5 +24,7 @@
# pragma warning(default: 4290) // C++ exception specification ignored except to ...
# pragma warning(default: 4180) // qualifier applied to function type has no meaning; ignored
# pragma warning(default: 4275) // non dll-interface class ... used as base for dll-interface class ...
+# pragma warning(default: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+# pragma warning(default: 4511) // 'class' : copy constructor could not be generated
# pragma warning(pop)
#endif
diff --git a/include/boost/test/detail/global_typedef.hpp b/include/boost/test/detail/global_typedef.hpp
index 4f81c50b..ad66f984 100644
--- a/include/boost/test/detail/global_typedef.hpp
+++ b/include/boost/test/detail/global_typedef.hpp
@@ -32,11 +32,11 @@ typedef unsigned long counter_t;
//____________________________________________________________________________//
-enum report_level { CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT, INV_REPORT_LEVEL };
+enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
//____________________________________________________________________________//
-enum output_format { CLF /* compiler log format */, XML /* XML */ };
+enum output_format { INV_OF, CLF /* compiler log format */, XML /* XML */ };
//____________________________________________________________________________//
@@ -45,6 +45,7 @@ enum test_unit_type { tut_case = 0x01, tut_suite = 0x10, tut_any = 0x11 };
//____________________________________________________________________________//
typedef unsigned long test_unit_id;
+
const test_unit_id INV_TEST_UNIT_ID = 0xFFFFFFFF;
const test_unit_id MAX_TEST_CASE_ID = 0xFFFFFFFE;
const test_unit_id MIN_TEST_CASE_ID = 0x00010000;
@@ -53,6 +54,8 @@ const test_unit_id MIN_TEST_SUITE_ID = 0x00000001;
//____________________________________________________________________________//
+namespace ut_detail {
+
inline test_unit_type
test_id_2_unit_type( test_unit_id id )
{
@@ -61,6 +64,19 @@ test_id_2_unit_type( test_unit_id id )
//____________________________________________________________________________//
+// helper templates to prevent ODR violations
+template
+struct static_constant {
+ static T value;
+};
+
+template
+T static_constant::value;
+
+//____________________________________________________________________________//
+
+} // namespace ut_detail
+
} // namespace unit_test
} // namespace boost
diff --git a/include/boost/test/detail/suppress_warnings.hpp b/include/boost/test/detail/suppress_warnings.hpp
index 02db5165..d5c95266 100644
--- a/include/boost/test/detail/suppress_warnings.hpp
+++ b/include/boost/test/detail/suppress_warnings.hpp
@@ -14,8 +14,8 @@
#ifdef BOOST_MSVC
# pragma warning(push)
-# pragma warning(disable: 4511) // copy constructor could not be generated
-# pragma warning(disable: 4512) // assignment operator could not be generated
+# pragma warning(disable: 4511) // copy constructor can't not be generated
+# pragma warning(disable: 4512) // assignment operator can't not be generated
# pragma warning(disable: 4100) // unreferenced formal parameter
# pragma warning(disable: 4996) // was declared deprecated
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
@@ -25,5 +25,7 @@
# pragma warning(disable: 4290) // C++ exception specification ignored except to ...
# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
# pragma warning(disable: 4275) // non dll-interface class ... used as base for dll-interface class ...
+# pragma warning(disable: 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
+# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
#endif
diff --git a/include/boost/test/detail/unit_test_parameters.hpp b/include/boost/test/detail/unit_test_parameters.hpp
index b07a9124..2a0814e6 100644
--- a/include/boost/test/detail/unit_test_parameters.hpp
+++ b/include/boost/test/detail/unit_test_parameters.hpp
@@ -32,7 +32,7 @@ namespace unit_test {
namespace runtime_config {
-void BOOST_TEST_DECL init( int* argc, char** argv );
+void BOOST_TEST_DECL init( int& argc, char** argv );
unit_test::log_level BOOST_TEST_DECL log_level();
bool BOOST_TEST_DECL no_result_code();
diff --git a/include/boost/test/detail/workaround.hpp b/include/boost/test/detail/workaround.hpp
index 05bf6e7d..a7c50c24 100644
--- a/include/boost/test/detail/workaround.hpp
+++ b/include/boost/test/detail/workaround.hpp
@@ -41,6 +41,9 @@ std::ptrdiff_t distance( T const& x_, T const& y_ )
return res;
}
+
+//____________________________________________________________________________//
+
#else
using std::distance;
#endif
diff --git a/include/boost/test/floating_point_comparison.hpp b/include/boost/test/floating_point_comparison.hpp
index ef0f773c..8ec7eb41 100644
--- a/include/boost/test/floating_point_comparison.hpp
+++ b/include/boost/test/floating_point_comparison.hpp
@@ -15,9 +15,15 @@
#ifndef BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
#define BOOST_TEST_FLOATING_POINT_COMPARISON_HPP_071894GER
-#include // for std::numeric_limits
-
+// Boost.Test
+#include
#include
+#include
+
+// Boost
+#include // for std::numeric_limits
+#include // for numeric::conversion_traits
+#include
#include
@@ -79,12 +85,12 @@ inline FPT
safe_fpt_division( FPT f1, FPT f2 )
{
// Avoid overflow.
- if( f2 < static_cast(1) && f1 > f2*fpt_limits::max_value() )
+ if( (f2 < static_cast(1)) && (f1 > f2*fpt_limits::max_value()) )
return fpt_limits::max_value();
// Avoid underflow.
- if( f1 == static_cast(0) ||
- f2 > static_cast(1) && f1 < f2*fpt_limits::min_value() )
+ if( (f1 == static_cast(0)) ||
+ ((f2 > static_cast(1)) && (f1 < f2*fpt_limits::min_value())) )
return static_cast(0);
return f1/f2;
@@ -166,28 +172,38 @@ public:
floating_point_comparison_type fpc_type = FPC_STRONG )
: p_fraction_tolerance( tt_detail::fpt_abs( static_cast(0.01)*tolerance.m_value ) )
, p_strong_or_weak( fpc_type == FPC_STRONG )
+ , m_report_modifier( 100. )
{}
template
explicit close_at_tolerance( fraction_tolerance_t tolerance,
floating_point_comparison_type fpc_type = FPC_STRONG )
: p_fraction_tolerance( tt_detail::fpt_abs( tolerance.m_value ) )
, p_strong_or_weak( fpc_type == FPC_STRONG )
+ , m_report_modifier( 1. )
{}
- bool operator()( FPT left, FPT right ) const
+ predicate_result operator()( FPT left, FPT right ) const
{
FPT diff = tt_detail::fpt_abs( left - right );
FPT d1 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( right ) );
FPT d2 = tt_detail::safe_fpt_division( diff, tt_detail::fpt_abs( left ) );
- return p_strong_or_weak
- ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get())
- : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get());
+ predicate_result res( p_strong_or_weak
+ ? (d1 <= p_fraction_tolerance.get() && d2 <= p_fraction_tolerance.get())
+ : (d1 <= p_fraction_tolerance.get() || d2 <= p_fraction_tolerance.get()) );
+
+ if( !res )
+ res.message() << (( d1 <= p_fraction_tolerance.get() ? d2 : d1 ) * m_report_modifier);
+
+ return res;
}
// Public properties
readonly_property p_fraction_tolerance;
readonly_property p_strong_or_weak;
+private:
+ // Data members
+ FPT m_report_modifier;
};
//____________________________________________________________________________//
@@ -200,20 +216,31 @@ struct BOOST_TEST_DECL check_is_close_t {
// Public typedefs
typedef bool result_type;
- template
- bool
- operator()( FPT left, FPT right, percent_tolerance_t tolerance,
- floating_point_comparison_type fpc_type = FPC_STRONG )
+ template
+ predicate_result
+ operator()( FPT1 left, FPT2 right, percent_tolerance_t tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG ) const
{
+ // deduce "better" type from types of arguments being compared
+ // if one type is floating and the second integral we use floating type and
+ // value of integral type is promoted to the floating. The same for float and double
+ // But we don't want to compare two values of integral types using this tool.
+ typedef typename numeric::conversion_traits::supertype FPT;
+ BOOST_STATIC_ASSERT( !is_integral::value );
+
close_at_tolerance pred( tolerance, fpc_type );
return pred( left, right );
}
- template
- bool
- operator()( FPT left, FPT right, fraction_tolerance_t tolerance,
- floating_point_comparison_type fpc_type = FPC_STRONG )
+ template
+ predicate_result
+ operator()( FPT1 left, FPT2 right, fraction_tolerance_t tolerance,
+ floating_point_comparison_type fpc_type = FPC_STRONG ) const
{
+ // same as in a comment above
+ typedef typename numeric::conversion_traits::supertype FPT;
+ BOOST_STATIC_ASSERT( !is_integral::value );
+
close_at_tolerance pred( tolerance, fpc_type );
return pred( left, right );
@@ -221,7 +248,7 @@ struct BOOST_TEST_DECL check_is_close_t {
};
namespace {
-check_is_close_t check_is_close;
+check_is_close_t const& check_is_close = unit_test::ut_detail::static_constant::value;
}
//____________________________________________________________________________//
@@ -236,14 +263,14 @@ struct BOOST_TEST_DECL check_is_small_t {
template
bool
- operator()( FPT fpv, FPT tolerance )
+ operator()( FPT fpv, FPT tolerance ) const
{
return tt_detail::fpt_abs( fpv ) < tt_detail::fpt_abs( tolerance );
}
};
namespace {
-check_is_small_t check_is_small;
+check_is_small_t const& check_is_small = unit_test::ut_detail::static_constant::value;
}
//____________________________________________________________________________//
diff --git a/include/boost/test/framework.hpp b/include/boost/test/framework.hpp
index 4390dcb6..7f6fd2ae 100644
--- a/include/boost/test/framework.hpp
+++ b/include/boost/test/framework.hpp
@@ -70,7 +70,7 @@ BOOST_TEST_DECL test_unit& get( test_unit_id, test_unit_type );
template
UnitType& get( test_unit_id id )
{
- return static_cast( get( id, (test_unit_type)UnitType::type ) );
+ return static_cast( get( id, static_cast(UnitType::type) ) );
}
// test initiation
@@ -94,6 +94,10 @@ struct setup_error : std::runtime_error {
setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
};
+#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg )
+
+struct nothing_to_test {}; // not really an error
+
} // namespace framework
} // unit_test
diff --git a/include/boost/test/impl/debug.ipp b/include/boost/test/impl/debug.ipp
index fcca3265..19960518 100644
--- a/include/boost/test/impl/debug.ipp
+++ b/include/boost/test/impl/debug.ipp
@@ -834,8 +834,8 @@ attach_debugger( bool break_or_continue )
bool created = !!::CreateProcessA(
NULL, // pointer to name of executable module; NULL - use the one in command line
cmd_line, // pointer to command line string
- NULL, // pointer to process security attributes; NULL - debugger's handle couldn't be inherited
- NULL, // pointer to thread security attributes; NULL - debugger's handle couldn't be inherited
+ NULL, // pointer to process security attributes; NULL - debugger's handle can't be inherited
+ NULL, // pointer to thread security attributes; NULL - debugger's handle can't be inherited
true, // debugger inherit opened handles
0, // priority flags; 0 - normal priority
NULL, // pointer to new environment block; NULL - use this process environment
diff --git a/include/boost/test/impl/exception_safety.ipp b/include/boost/test/impl/exception_safety.ipp
index dbd6f675..7f0afcb4 100644
--- a/include/boost/test/impl/exception_safety.ipp
+++ b/include/boost/test/impl/exception_safety.ipp
@@ -166,7 +166,7 @@ exception_safety_tester::exception_safety_tester( const_string test_name )
, m_forced_exception_point( 1 )
, m_exec_path_point( 0 )
, m_exec_path_counter( 1 )
-, m_break_exec_path( (unsigned)-1 )
+, m_break_exec_path( static_cast(-1) )
, m_invairant_failed( false )
{
framework::register_observer( *this );
@@ -447,7 +447,7 @@ format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt e
unsigned i;
for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) {
- unsigned char c = ((unsigned char*)it->m_alloc.ptr)[i];
+ unsigned char c = static_cast(it->m_alloc.ptr)[i];
if( (std::isprint)( c ) )
formatter << c;
else
@@ -457,7 +457,7 @@ format_execution_path( wrap_stringstream& formatter, ExecPathIt it, ExecPathIt e
formatter << "> ";
for( i = 0; i < std::min( it->m_alloc.size, 8 ); i++ ) {
- unsigned c = ((unsigned char*)it->m_alloc.ptr)[i];
+ unsigned c = static_cast(it->m_alloc.ptr)[i];
formatter << std::hex << std::uppercase << c << ' ';
}
@@ -491,7 +491,7 @@ exception_safety_tester::report_error()
if( m_invairant_failed )
formatter << " and ";
- formatter << (unsigned int)m_memory_in_use.size() << " memory leak";
+ formatter << static_cast(m_memory_in_use.size()) << " memory leak";
if( m_memory_in_use.size() > 1 )
formatter << 's';
}
diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp
index eb183be2..dbf2443f 100644
--- a/include/boost/test/impl/execution_monitor.ipp
+++ b/include/boost/test/impl/execution_monitor.ipp
@@ -114,8 +114,16 @@ typedef void* uintptr_t;
#endif
# if !defined(NDEBUG) && defined(_MSC_VER) && !defined(UNDER_CE)
-# define BOOST_TEST_USE_DEBUG_MS_CRT
# include
+# define BOOST_TEST_CRT_HOOK_TYPE _CRT_REPORT_HOOK
+# define BOOST_TEST_CRT_ASSERT _CRT_ASSERT
+# define BOOST_TEST_CRT_ERROR _CRT_ERROR
+# define BOOST_TEST_CRT_SET_HOOK(H) _CrtSetReportHook(H)
+# else
+# define BOOST_TEST_CRT_HOOK_TYPE void*
+# define BOOST_TEST_CRT_ASSERT 2
+# define BOOST_TEST_CRT_ERROR 1
+# define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H)
# endif
# if !BOOST_WORKAROUND(_MSC_VER, >= 1400 ) || defined(UNDER_CE)
@@ -144,6 +152,25 @@ namespace { void _set_se_translator( void* ) {} }
# include
# include
+# if defined(__FreeBSD__)
+
+# ifndef SIGPOLL
+# define SIGPOLL SIGIO
+# endif
+
+# if (__FreeBSD_version < 70100)
+
+# define ILL_ILLADR 0 // ILL_RESAD_FAULT
+# define ILL_PRVOPC ILL_PRIVIN_FAULT
+# define ILL_ILLOPN 2 // ILL_RESOP_FAULT
+# define ILL_COPROC ILL_FPOP_FAULT
+
+# define BOOST_TEST_LIMITED_SIGNAL_DETAILS
+# define BOOST_TEST_IGNORE_SIGCHLD
+
+# endif
+# endif
+
# if !defined(__CYGWIN__) && !defined(__QNXNTO__)
# define BOOST_TEST_USE_ALT_STACK
# endif
@@ -200,7 +227,9 @@ report_error( execution_exception::error_code ec, char const* format, ... )
va_list args;
va_start( args, format );
- BOOST_TEST_VSNPRINTF( buf, sizeof(buf), format, args );
+ BOOST_TEST_VSNPRINTF( buf, sizeof(buf)-1, format, args );
+ buf[sizeof(buf)-1] = 0;
+
va_end( args );
throw execution_exception( ec, buf );
@@ -290,11 +319,28 @@ system_signal_exception::report() const
switch( m_sig_info->si_signo ) {
case SIGILL:
switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
case ILL_ILLOPC:
report_error( execution_exception::system_fatal_error,
"signal: illegal opcode; address of failing instruction: 0x%08lx",
m_sig_info->si_addr );
break;
+ case ILL_ILLTRP:
+ report_error( execution_exception::system_fatal_error,
+ "signal: illegal trap; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_PRVREG:
+ report_error( execution_exception::system_fatal_error,
+ "signal: privileged register; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+ case ILL_BADSTK:
+ report_error( execution_exception::system_fatal_error,
+ "signal: internal stack error; address of failing instruction: 0x%08lx",
+ m_sig_info->si_addr );
+ break;
+#endif
case ILL_ILLOPN:
report_error( execution_exception::system_fatal_error,
"signal: illegal operand; address of failing instruction: 0x%08lx",
@@ -305,30 +351,20 @@ system_signal_exception::report() const
"signal: illegal addressing mode; address of failing instruction: 0x%08lx",
m_sig_info->si_addr );
break;
- case ILL_ILLTRP:
- report_error( execution_exception::system_fatal_error,
- "signal: illegal trap; address of failing instruction: 0x%08lx",
- m_sig_info->si_addr );
- break;
case ILL_PRVOPC:
report_error( execution_exception::system_fatal_error,
"signal: privileged opcode; address of failing instruction: 0x%08lx",
m_sig_info->si_addr );
break;
- case ILL_PRVREG:
- report_error( execution_exception::system_fatal_error,
- "signal: privileged register; address of failing instruction: 0x%08lx",
- m_sig_info->si_addr );
- break;
case ILL_COPROC:
report_error( execution_exception::system_fatal_error,
"signal: co-processor error; address of failing instruction: 0x%08lx",
m_sig_info->si_addr );
break;
- case ILL_BADSTK:
- report_error( execution_exception::system_fatal_error,
- "signal: internal stack error; address of failing instruction: 0x%08lx",
- m_sig_info->si_addr );
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGILL, si_code: %d (illegal instruction; address of failing instruction: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
break;
}
break;
@@ -375,11 +411,17 @@ system_signal_exception::report() const
"signal: subscript out of range; address of failing instruction: 0x%08lx",
m_sig_info->si_addr );
break;
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGFPE, si_code: %d (errnoneous arithmetic operations; address of failing instruction: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
}
break;
case SIGSEGV:
switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
case SEGV_MAPERR:
report_error( execution_exception::system_fatal_error,
"memory access violation at address: 0x%08lx: no mapping at fault address",
@@ -390,11 +432,18 @@ system_signal_exception::report() const
"memory access violation at address: 0x%08lx: invalid permissions",
m_sig_info->si_addr );
break;
+#endif
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
}
break;
case SIGBUS:
switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
case BUS_ADRALN:
report_error( execution_exception::system_fatal_error,
"memory access violation at address: 0x%08lx: invalid address alignment",
@@ -410,11 +459,18 @@ system_signal_exception::report() const
"memory access violation at address: 0x%08lx: object specific hardware error",
m_sig_info->si_addr );
break;
+#endif
+ default:
+ report_error( execution_exception::system_fatal_error,
+ "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)",
+ m_sig_info->si_addr, m_sig_info->si_code );
+ break;
}
break;
case SIGCHLD:
switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
case CLD_EXITED:
report_error( execution_exception::system_error,
"child has exited; pid: %d; uid: %d; exit value: %d",
@@ -445,6 +501,12 @@ system_signal_exception::report() const
"stopped child had continued; pid: %d; uid: %d; exit value: %d",
(int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status );
break;
+#endif
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGCHLD, si_code: %d (child process has terminated; pid: %d; uid: %d; exit value: %d)",
+ (int)m_sig_info->si_pid, (int)m_sig_info->si_uid, (int)m_sig_info->si_status, m_sig_info->si_code );
+ break;
}
break;
@@ -452,6 +514,7 @@ system_signal_exception::report() const
case SIGPOLL:
switch( m_sig_info->si_code ) {
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
case POLL_IN:
report_error( execution_exception::system_error,
"data input available; band event %d",
@@ -484,6 +547,12 @@ system_signal_exception::report() const
(int)m_sig_info->si_band );
break;
#endif
+#endif
+ default:
+ report_error( execution_exception::system_error,
+ "signal: SIGPOLL, si_code: %d (asynchronous I/O event occured; band event %d)",
+ (int)m_sig_info->si_band, m_sig_info->si_code );
+ break;
}
break;
@@ -520,7 +589,8 @@ class signal_action {
typedef struct sigaction* sigaction_ptr;
public:
//Constructor
- explicit signal_action( int sig, bool install, bool attach_dbg, char* alt_stack );
+ signal_action();
+ signal_action( int sig, bool install, bool attach_dbg, char* alt_stack );
~signal_action();
private:
@@ -533,6 +603,12 @@ private:
//____________________________________________________________________________//
+signal_action::signal_action()
+: m_installed( false )
+{}
+
+//____________________________________________________________________________//
+
signal_action::signal_action( int sig, bool install, bool attach_dbg, char* alt_stack )
: m_sig( sig )
, m_installed( install )
@@ -609,9 +685,7 @@ private:
signal_action m_SEGV_action;
signal_action m_BUS_action;
signal_action m_CHLD_action;
-#ifdef BOOST_TEST_CATCH_SIGPOLL
signal_action m_POLL_action;
-#endif
signal_action m_ABRT_action;
signal_action m_ALRM_action;
@@ -634,7 +708,9 @@ signal_handler::signal_handler( bool catch_system_errors, int timeout, bool atta
, m_FPE_action ( SIGFPE , catch_system_errors, attach_dbg, alt_stack )
, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack )
, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack )
+#ifndef BOOST_TEST_IGNORE_SIGCHLD
, m_CHLD_action( SIGCHLD, catch_system_errors, attach_dbg, alt_stack )
+#endif
#ifdef BOOST_TEST_CATCH_SIGPOLL
, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack )
#endif
@@ -695,7 +771,10 @@ extern "C" {
static bool ignore_sigchild( siginfo_t* info )
{
- return info->si_signo == SIGCHLD && info->si_code == CLD_EXITED
+ return info->si_signo == SIGCHLD
+#ifndef BOOST_TEST_LIMITED_SIGNAL_DETAILS
+ && info->si_code == CLD_EXITED
+#endif
#ifdef BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE
;
#else
@@ -807,7 +886,7 @@ private:
static void
seh_catch_preventer( unsigned int /* id */, _EXCEPTION_POINTERS* /* exps */ )
{
- throw;
+ throw;
}
//____________________________________________________________________________//
@@ -941,21 +1020,19 @@ system_signal_exception::report() const
//____________________________________________________________________________//
-#if defined(BOOST_TEST_USE_DEBUG_MS_CRT)
-
// ************************************************************************** //
// ************** assert_reporting_function ************** //
// ************************************************************************** //
int BOOST_TEST_CALL_DECL
-assert_reporting_function( int reportType, char* userMessage, int* retVal )
+assert_reporting_function( int reportType, char* userMessage, int* )
{
switch( reportType ) {
- case _CRT_ASSERT:
+ case BOOST_TEST_CRT_ASSERT:
detail::report_error( execution_exception::user_error, userMessage );
return 1; // return value and retVal are not important since we never reach this line
- case _CRT_ERROR:
+ case BOOST_TEST_CRT_ERROR:
detail::report_error( execution_exception::system_error, userMessage );
return 1; // return value and retVal are not important since we never reach this line
@@ -964,8 +1041,6 @@ assert_reporting_function( int reportType, char* userMessage, int* retVal )
}
} // assert_reporting_function
-#endif
-
//____________________________________________________________________________//
void BOOST_TEST_CALL_DECL
@@ -1015,6 +1090,7 @@ int
execution_monitor::catch_signals( unit_test::callback0 const& F )
{
_invalid_parameter_handler old_iph = _invalid_parameter_handler();
+ BOOST_TEST_CRT_HOOK_TYPE old_crt_hook;
if( !p_catch_system_errors )
_set_se_translator( &detail::seh_catch_preventer );
@@ -1022,9 +1098,7 @@ execution_monitor::catch_signals( unit_test::callback0 const& F )
if( !!p_detect_fp_exceptions )
detail::switch_fp_exceptions( true );
-#ifdef BOOST_TEST_USE_DEBUG_MS_CRT
- _CrtSetReportHook( &detail::assert_reporting_function );
-#endif
+ old_crt_hook = BOOST_TEST_CRT_SET_HOOK( &detail::assert_reporting_function );
old_iph = _set_invalid_parameter_handler(
reinterpret_cast<_invalid_parameter_handler>( &detail::invalid_param_handler ) );
@@ -1047,6 +1121,8 @@ execution_monitor::catch_signals( unit_test::callback0 const& F )
if( !!p_detect_fp_exceptions )
detail::switch_fp_exceptions( false );
+ BOOST_TEST_CRT_SET_HOOK( old_crt_hook );
+
_set_invalid_parameter_handler( old_iph );
}
}
diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp
index 7392407d..ed9919c7 100644
--- a/include/boost/test/impl/framework.ipp
+++ b/include/boost/test/impl/framework.ipp
@@ -127,10 +127,10 @@ public:
test_unit_store::value_type const& tu = *m_test_units.begin();
// the delete will erase this element from map
- if( test_id_2_unit_type( tu.second->p_id ) == tut_suite )
- delete (test_suite const*)tu.second;
+ if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == tut_suite )
+ delete static_cast(tu.second);
else
- delete (test_case const*)tu.second;
+ delete static_cast(tu.second);
}
}
@@ -219,7 +219,11 @@ public:
namespace {
+#if defined(__CYGWIN__)
+framework_impl& s_frk_impl() { static framework_impl* the_inst = 0; if(!the_inst) the_inst = new framework_impl; return *the_inst; }
+#else
framework_impl& s_frk_impl() { static framework_impl the_inst; return the_inst; }
+#endif
} // local namespace
@@ -230,7 +234,7 @@ namespace framework {
void
init( init_unit_test_func init_func, int argc, char* argv[] )
{
- runtime_config::init( &argc, argv );
+ runtime_config::init( argc, argv );
// set the log level and format
unit_test_log.set_threshold_level( runtime_config::log_level() );
@@ -282,13 +286,11 @@ is_initialized()
void
register_test_unit( test_case* tc )
{
- if( tc->p_id != INV_TEST_UNIT_ID )
- throw setup_error( BOOST_TEST_L( "test case already registered" ) );
+ BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) );
test_unit_id new_id = s_frk_impl().m_next_test_case_id;
- if( new_id == MAX_TEST_CASE_ID )
- throw setup_error( BOOST_TEST_L( "too many test cases" ) );
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) );
typedef framework_impl::test_unit_store::value_type map_value_type;
@@ -303,13 +305,11 @@ register_test_unit( test_case* tc )
void
register_test_unit( test_suite* ts )
{
- if( ts->p_id != INV_TEST_UNIT_ID )
- throw setup_error( BOOST_TEST_L( "test suite already registered" ) );
+ BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) );
test_unit_id new_id = s_frk_impl().m_next_test_suite_id;
- if( new_id == MAX_TEST_SUITE_ID )
- throw setup_error( BOOST_TEST_L( "too many test suites" ) );
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) );
typedef framework_impl::test_unit_store::value_type map_value_type;
s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) );
@@ -401,10 +401,9 @@ run( test_unit_id id, bool continue_test )
test_case_counter tcc;
traverse_test_tree( id, tcc );
- if( tcc.p_count == 0 )
- throw setup_error( runtime_config::test_to_run().is_empty()
- ? BOOST_TEST_L( "test tree is empty" )
- : BOOST_TEST_L( "no test cases matching filter" ) );
+ BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty()
+ ? BOOST_TEST_L( "test tree is empty" )
+ : BOOST_TEST_L( "no test cases matching filter" ) );
bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress;
bool was_in_progress = s_frk_impl().m_test_in_progress;
@@ -428,7 +427,7 @@ run( test_unit_id id, bool continue_test )
case 0:
break;
case 1: {
- unsigned int seed = (unsigned int)std::time( 0 );
+ unsigned int seed = static_cast( std::time( 0 ) );
BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed );
std::srand( seed );
break;
diff --git a/include/boost/test/impl/interaction_based.ipp b/include/boost/test/impl/interaction_based.ipp
index 8df4ae86..ce289336 100644
--- a/include/boost/test/impl/interaction_based.ipp
+++ b/include/boost/test/impl/interaction_based.ipp
@@ -66,8 +66,7 @@ manager::instance_ptr( bool reset, manager* new_ptr )
if( reset ) {
if( new_ptr ) {
- if( ptr != &dummy )
- throw unit_test::framework::setup_error( BOOST_TEST_L( "Couldn't run two interation based test the same time" ) );
+ BOOST_TEST_SETUP_ASSERT( ptr == &dummy, BOOST_TEST_L( "Can't run two interation based test the same time" ) );
ptr = new_ptr;
}
diff --git a/include/boost/test/impl/logged_expectations.ipp b/include/boost/test/impl/logged_expectations.ipp
index be8a52f6..ff30628b 100644
--- a/include/boost/test/impl/logged_expectations.ipp
+++ b/include/boost/test/impl/logged_expectations.ipp
@@ -85,7 +85,7 @@ expectations_logger::expectations_logger( const_string log_file_name, bool test_
m_log_file.open( log_file_name.begin(), test_or_log ? std::ios::in : std::ios::out );
BOOST_REQUIRE_MESSAGE( m_log_file.is_open(),
- "Couldn't open expectations log file " << log_file_name
+ "Can't open expectations log file " << log_file_name
<< " for " << ( m_test_or_log ? "reading" : "writing") );
if( m_test_or_log ) {
diff --git a/include/boost/test/impl/results_collector.ipp b/include/boost/test/impl/results_collector.ipp
index 64dd7546..2d07fcdb 100644
--- a/include/boost/test/impl/results_collector.ipp
+++ b/include/boost/test/impl/results_collector.ipp
@@ -215,9 +215,9 @@ results_collector_t::test_unit_finish( test_unit const& tu, unsigned long )
if( !num_failures_match )
BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " has fewer failures than expected" );
- bool has_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0);
- if( !has_any_assertions )
- BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " doesn't include any assertions" );
+ bool run_any_assertions = tr.p_aborted || (tr.p_assertions_failed != 0) || (tr.p_assertions_passed != 0);
+ if( !run_any_assertions )
+ BOOST_TEST_MESSAGE( "Test case " << tu.p_name << " did not run any assertions" );
}
}
diff --git a/include/boost/test/impl/results_reporter.ipp b/include/boost/test/impl/results_reporter.ipp
index 3ff16fe5..e9ef2fa2 100644
--- a/include/boost/test/impl/results_reporter.ipp
+++ b/include/boost/test/impl/results_reporter.ipp
@@ -130,6 +130,8 @@ set_format( output_format rf )
case XML:
set_format( new output::xml_report_formatter );
break;
+ default:
+ break;
}
}
diff --git a/include/boost/test/impl/test_tools.ipp b/include/boost/test/impl/test_tools.ipp
index 3ddb99fd..6f5d7e9e 100644
--- a/include/boost/test/impl/test_tools.ipp
+++ b/include/boost/test/impl/test_tools.ipp
@@ -60,7 +60,7 @@ namespace test_tools {
void
print_log_value::operator()( std::ostream& ostr, char t )
{
- if( (std::isprint)( (unsigned char)t ) )
+ if( (std::isprint)( static_cast(t) ) )
ostr << '\'' << t << '\'';
else
ostr << std::hex
@@ -69,7 +69,7 @@ print_log_value::operator()( std::ostream& ostr, char t )
#else
<< "0x"
#endif
- << (int)t;
+ << static_cast(t);
}
//____________________________________________________________________________//
@@ -84,7 +84,7 @@ print_log_value::operator()( std::ostream& ostr, unsigned char t
#else
<< "0x"
#endif
- << (int)t;
+ << static_cast(t);
}
//____________________________________________________________________________//
@@ -227,18 +227,16 @@ check_impl( predicate_result const& pr, lazy_ostream const& check_descr,
unit_test_log << unit_test::log::begin( file_name, line_num ) << ll;
- unit_test_log << "difference between " << arg1_descr << "{" << *arg1_val << "}"
- << " and " << arg2_descr << "{" << *arg2_val << "}"
- << ( tl == PASS ? " doesn't exceed " : " exceeds " )
+ unit_test_log << "difference{" << pr.message() << (ct == CHECK_CLOSE ? "%" : "")
+ << "} between " << arg1_descr << "{" << *arg1_val
+ << "} and " << arg2_descr << "{" << *arg2_val
+ << ( tl == PASS ? "} doesn't exceed " : "} exceeds " )
<< *toler_val;
if( ct == CHECK_CLOSE )
unit_test_log << "%";
va_end( args );
- if( !pr.has_empty_message() )
- unit_test_log << ". " << pr.message();
-
unit_test_log << unit_test::log::end();
break;
}
@@ -451,7 +449,7 @@ output_test_stream::output_test_stream( const_string pattern_file_name, bool mat
m_pimpl->m_pattern.open( pattern_file_name.begin(), m );
BOOST_WARN_MESSAGE( m_pimpl->m_pattern.is_open(),
- "Couldn't open pattern file " << pattern_file_name
+ "Can't open pattern file " << pattern_file_name
<< " for " << (match_or_save ? "reading" : "writing") );
}
@@ -528,7 +526,7 @@ output_test_stream::match_pattern( bool flush_stream )
if( !m_pimpl->m_pattern.is_open() ) {
result = false;
- result.message() << "Pattern file could not be opened!";
+ result.message() << "Pattern file can't be opened!";
}
else {
if( m_pimpl->m_match_or_save ) {
diff --git a/include/boost/test/impl/unit_test_main.ipp b/include/boost/test/impl/unit_test_main.ipp
index 7648e656..adedf351 100644
--- a/include/boost/test/impl/unit_test_main.ipp
+++ b/include/boost/test/impl/unit_test_main.ipp
@@ -23,7 +23,8 @@
#include
-#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
+#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 )
+#define BOOST_TEST_SUPPORT_RUN_BY_NAME
#include
#endif
@@ -100,13 +101,13 @@ public:
const_string m_value;
};
// Constructor
-#if defined(__BORLANDC__) || BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
+#ifndef BOOST_TEST_SUPPORT_RUN_BY_NAME
explicit test_case_filter( const_string ) : m_depth( 0 ) {}
#else
- explicit test_case_filter( const_string tc_to_tun )
+ explicit test_case_filter( const_string tc_to_run )
: m_depth( 0 )
{
- string_token_iterator tit( tc_to_tun, (dropped_delimeters = "/", kept_delimeters = dt_none) );
+ string_token_iterator tit( tc_to_run, (dropped_delimeters = "/", kept_delimeters = dt_none) );
while( tit != string_token_iterator() ) {
m_filters.push_back(
@@ -186,9 +187,12 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
results_reporter::make_report();
return runtime_config::no_result_code()
- ? boost::exit_success
+ ? boost::exit_success
: results_collector.results( framework::master_test_suite().p_id ).result_code();
}
+ catch( framework::nothing_to_test const& ) {
+ return boost::exit_success;
+ }
catch( framework::internal_error const& ex ) {
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp
index e46b596a..e15fd61b 100644
--- a/include/boost/test/impl/unit_test_parameters.ipp
+++ b/include/boost/test/impl/unit_test_parameters.ipp
@@ -25,6 +25,22 @@
#include
#include
#include
+#include
+
+// Boost.Runtime.Param
+#include
+#include
+
+namespace rt = boost::runtime;
+namespace cla = rt::cla;
+
+
+#ifndef UNDER_CE
+#include
+
+namespace env = rt::env;
+#endif
+
// Boost
#include
@@ -35,6 +51,7 @@
// STL
#include