|
Boost-Commit : |
From: gennadiy.rozental_at_[hidden]
Date: 2007-10-21 16:53:57
Author: rogeeff
Date: 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
New Revision: 40270
URL: http://svn.boost.org/trac/boost/changeset/40270
Log:
Missing header in exception_safety.hpp
Run by name support
new tools BOOST_CHECK_NE, BOOST_CHECK_LE, BOOST_CHECK_LT, BOOST_CHECK_GE, BOOST_CHECK_GT implemented
Text files modified:
trunk/boost/test/exception_safety.hpp | 1
trunk/boost/test/impl/framework.ipp | 8 +
trunk/boost/test/impl/progress_monitor.ipp | 2
trunk/boost/test/impl/results_collector.ipp | 2
trunk/boost/test/impl/test_tools.ipp | 14 +++
trunk/boost/test/impl/unit_test_main.ipp | 128 +++++++++++++++++++++++++++++++++++++++
trunk/boost/test/impl/unit_test_suite.ipp | 13 ++++
trunk/boost/test/test_tools.hpp | 102 +++++++++++++++++++++++++++++++
trunk/boost/test/unit_test_suite_impl.hpp | 14 ++-
9 files changed, 267 insertions(+), 17 deletions(-)
Modified: trunk/boost/test/exception_safety.hpp
==============================================================================
--- trunk/boost/test/exception_safety.hpp (original)
+++ trunk/boost/test/exception_safety.hpp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -19,6 +19,7 @@
#include <boost/test/detail/config.hpp>
#include <boost/test/utils/callback.hpp>
+#include <boost/test/utils/basic_cstring/basic_cstring_fwd.hpp>
// STL
#include <memory>
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -367,8 +367,10 @@
test_case_counter tcc;
traverse_test_tree( id, tcc );
- if( tcc.m_count == 0 )
- throw setup_error( BOOST_TEST_L( "test tree is empty" ) );
+ 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" ) );
bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress;
bool was_in_progress = s_frk_impl().m_test_in_progress;
@@ -380,7 +382,7 @@
boost::execution_monitor em;
try {
- em.execute( ut_detail::test_start_caller( to, tcc.m_count ) );
+ em.execute( ut_detail::test_start_caller( to, tcc.p_count ) );
}
catch( execution_exception const& ex ) {
throw setup_error( ex.what() );
Modified: trunk/boost/test/impl/progress_monitor.ipp
==============================================================================
--- trunk/boost/test/impl/progress_monitor.ipp (original)
+++ trunk/boost/test/impl/progress_monitor.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -84,7 +84,7 @@
test_case_counter tcc;
traverse_test_tree( tu, tcc );
- (*s_pm_impl().m_progress_display) += tcc.m_count;
+ (*s_pm_impl().m_progress_display) += tcc.p_count;
}
//____________________________________________________________________________//
Modified: trunk/boost/test/impl/results_collector.ipp
==============================================================================
--- trunk/boost/test/impl/results_collector.ipp (original)
+++ trunk/boost/test/impl/results_collector.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -231,7 +231,7 @@
tr.clear();
tr.p_skipped.value = true;
- tr.p_test_cases_skipped.value = tcc.m_count;
+ tr.p_test_cases_skipped.value = tcc.p_count;
}
}
Modified: trunk/boost/test/impl/test_tools.ipp
==============================================================================
--- trunk/boost/test/impl/test_tools.ipp (original)
+++ trunk/boost/test/impl/test_tools.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -125,7 +125,15 @@
unit_test_log << unit_test::log::end();
break;
- case CHECK_EQUAL: {
+ case CHECK_EQUAL:
+ case CHECK_NE:
+ case CHECK_LT:
+ case CHECK_LE:
+ case CHECK_GT:
+ case CHECK_GE: {
+ static char const* check_str [] = { " == ", " != ", " < " , " <= ", " > " , " >= " };
+ static char const* rever_str [] = { " != ", " == ", " >= ", " > " , " <= ", " < " };
+
va_list args;
va_start( args, num_of_args );
@@ -135,10 +143,10 @@
char const* arg2_val = va_arg( args, char const* );
unit_test_log << unit_test::log::begin( file_name, line_num )
- << ll << prefix << arg1_descr << " == " << arg2_descr << suffix;
+ << ll << prefix << arg1_descr << check_str[ct-CHECK_EQUAL] << arg2_descr << suffix;
if( tl != PASS )
- unit_test_log << " [" << arg1_val << " != " << arg2_val << "]" ;
+ unit_test_log << " [" << arg1_val << rever_str[ct-CHECK_EQUAL] << arg2_val << "]" ;
va_end( args );
Modified: trunk/boost/test/impl/unit_test_main.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_main.ipp (original)
+++ trunk/boost/test/impl/unit_test_main.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -23,8 +23,13 @@
#include <boost/test/detail/unit_test_parameters.hpp>
+#if !defined(__BORLANDC__) && BOOST_WORKAROUND( BOOST_MSVC, >= 1300 )
+#include <boost/test/utils/iterator/token_iterator.hpp>
+#endif
+
// Boost
#include <boost/cstdlib.hpp>
+#include <boost/bind.hpp>
// STL
#include <stdexcept>
@@ -39,6 +44,121 @@
namespace unit_test {
// ************************************************************************** //
+// ************** test_case_filter ************** //
+// ************************************************************************** //
+
+class test_case_filter : public test_tree_visitor {
+public:
+ struct single_filter {
+ single_filter( const_string in )
+ {
+ if( in == "*" )
+ m_kind = SFK_ALL;
+ else if( first_char( in ) == '*' && last_char( in ) == '*' ) {
+ m_kind = SFK_SUBSTR;
+ m_value = in.substr( 1, in.size()-1 );
+ }
+ else if( first_char( in ) == '*' ) {
+ m_kind = SFK_TRAILING;
+ m_value = in.substr( 1 );
+ }
+ else if( last_char( in ) == '*' ) {
+ m_kind = SFK_LEADING;
+ m_value = in.substr( 0, in.size()-1 );
+ }
+ else {
+ m_kind = SFK_MATCH;
+ m_value = in;
+ }
+ };
+
+ bool pass( test_unit const& tu ) const
+ {
+ const_string name( tu.p_name );
+
+ switch( m_kind ) {
+ default:
+ case SFK_ALL:
+ return true;
+
+ case SFK_LEADING:
+ return name.substr( 0, m_value.size() ) == m_value;
+
+ case SFK_TRAILING:
+ return name.size() >= m_value.size() && name.substr( name.size() - m_value.size() ) == m_value;
+
+ case SFK_SUBSTR:
+ return name.find( m_value ) != const_string::npos;
+
+ case SFK_MATCH:
+ return m_value == tu.p_name.get();
+ }
+ }
+ enum kind { SFK_ALL, SFK_LEADING, SFK_TRAILING, SFK_SUBSTR, SFK_MATCH };
+
+ kind m_kind;
+ const_string m_value;
+ };
+ // Constructor
+ explicit test_case_filter( const_string tc_to_tun )
+ : m_depth( 0 )
+ {
+#if !defined(__BORLANDC__) && BOOST_WORKAROUND( BOOST_MSVC, >= 1300 )
+ string_token_iterator tit( tc_to_tun, (dropped_delimeters = "/", kept_delimeters = dt_none) );
+
+ while( tit != string_token_iterator() ) {
+ m_filters.push_back(
+ std::vector<single_filter>( string_token_iterator( *tit, (dropped_delimeters = ",", kept_delimeters = dt_none) ),
+ string_token_iterator() ) );
+
+ ++tit;
+ }
+#endif
+ }
+
+ void filter_unit( test_unit const& tu )
+ {
+ if( (++m_depth - 1) > m_filters.size() ) {
+ tu.p_enabled.value = true;
+ return;
+ }
+
+ if( m_depth == 1 )
+ return;
+
+ std::vector<single_filter> const& filters = m_filters[m_depth-2];
+
+ tu.p_enabled.value =
+ std::find_if( filters.begin(), filters.end(), bind( &single_filter::pass, _1, tu ) ) != filters.end();
+ }
+
+ // test tree visitor interface
+ virtual void visit( test_case const& tc )
+ {
+ filter_unit( tc );
+
+ --m_depth;
+ }
+
+ virtual bool test_suite_start( test_suite const& ts )
+ {
+ filter_unit( ts );
+
+ if( !ts.p_enabled )
+ --m_depth;
+
+ return ts.p_enabled;
+ }
+
+ virtual void test_suite_finish( test_suite const& ) { --m_depth; }
+
+private:
+ // Data members
+ std::vector<std::vector<single_filter> > m_filters;
+ unsigned m_depth;
+};
+
+// ************************************************************************** //
// ************** unit_test_main ************** //
// ************************************************************************** //
@@ -48,9 +168,11 @@
try {
framework::init( init_func, argc, argv );
-// !! ?? if( !runtime_config.test_to_run().is_empty() ) {
-//
-// }
+ if( !runtime_config::test_to_run().is_empty() ) {
+ test_case_filter filter( runtime_config::test_to_run() );
+
+ traverse_test_tree( framework::master_test_suite().p_id, filter );
+ }
framework::run();
Modified: trunk/boost/test/impl/unit_test_suite.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_suite.ipp (original)
+++ trunk/boost/test/impl/unit_test_suite.ipp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -223,6 +223,19 @@
//____________________________________________________________________________//
// ************************************************************************** //
+// ************** test_case_counter ************** //
+// ************************************************************************** //
+
+void
+test_case_counter::visit( test_case const& tc )
+{
+ if( tc.p_enabled )
+ ++p_count.value;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
// ************** object generators ************** //
// ************************************************************************** //
Modified: trunk/boost/test/test_tools.hpp
==============================================================================
--- trunk/boost/test/test_tools.hpp (original)
+++ trunk/boost/test/test_tools.hpp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -164,6 +164,51 @@
//____________________________________________________________________________//
+#define BOOST_WARN_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ne_impl(), "", WARN, CHECK_NE, (L)(R) )
+#define BOOST_CHECK_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ne_impl(), "", CHECK, CHECK_NE, (L)(R) )
+#define BOOST_REQUIRE_NE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ne_impl(), "", REQUIRE, CHECK_NE, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::lt_impl(), "", WARN, CHECK_LT, (L)(R) )
+#define BOOST_CHECK_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::lt_impl(), "", CHECK, CHECK_LT, (L)(R) )
+#define BOOST_REQUIRE_LT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::lt_impl(), "", REQUIRE, CHECK_LT, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::le_impl(), "", WARN, CHECK_LE, (L)(R) )
+#define BOOST_CHECK_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::le_impl(), "", CHECK, CHECK_LE, (L)(R) )
+#define BOOST_REQUIRE_LE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::le_impl(), "", REQUIRE, CHECK_LE, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::gt_impl(), "", WARN, CHECK_GT, (L)(R) )
+#define BOOST_CHECK_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::gt_impl(), "", CHECK, CHECK_GT, (L)(R) )
+#define BOOST_REQUIRE_GT( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::gt_impl(), "", REQUIRE, CHECK_GT, (L)(R) )
+
+//____________________________________________________________________________//
+
+#define BOOST_WARN_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ge_impl(), "", WARN, CHECK_GE, (L)(R) )
+#define BOOST_CHECK_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ge_impl(), "", CHECK, CHECK_GE, (L)(R) )
+#define BOOST_REQUIRE_GE( L, R ) \
+ BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::tt_detail::ge_impl(), "", REQUIRE, CHECK_GE, (L)(R) )
+
+//____________________________________________________________________________//
+
#define BOOST_WARN_CLOSE( L, R, T ) \
BOOST_CHECK_WITH_ARGS_IMPL( ::boost::test_tools::check_is_close, "", WARN, CHECK_CLOSE, \
(L)(R)(::boost::test_tools::percent_tolerance(T)) )
@@ -265,6 +310,11 @@
CHECK_PRED,
CHECK_MSG,
CHECK_EQUAL,
+ CHECK_NE,
+ CHECK_LT,
+ CHECK_LE,
+ CHECK_GT,
+ CHECK_GE,
CHECK_CLOSE,
CHECK_CLOSE_FRACTION,
CHECK_SMALL,
@@ -483,7 +533,7 @@
//____________________________________________________________________________//
-struct BOOST_TEST_DECL equal_impl_frwd {
+struct equal_impl_frwd {
template <typename Left, typename Right>
inline predicate_result
call_impl( Left const& left, Right const& right, mpl::false_ ) const
@@ -509,6 +559,56 @@
//____________________________________________________________________________//
+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;
+ }
+};
+
+//____________________________________________________________________________//
+
template <typename Left, typename Right>
inline predicate_result
equal_coll_impl( Left left_begin, Left left_end, Right right_begin, Right right_end )
Modified: trunk/boost/test/unit_test_suite_impl.hpp
==============================================================================
--- trunk/boost/test/unit_test_suite_impl.hpp (original)
+++ trunk/boost/test/unit_test_suite_impl.hpp 2007-10-21 16:53:56 EDT (Sun, 21 Oct 2007)
@@ -196,12 +196,16 @@
// ************** test_case_counter ************** //
// ************************************************************************** //
-struct test_case_counter : test_tree_visitor {
- test_case_counter() : m_count( 0 ) {}
-
- virtual void visit( test_case const& ) { m_count++; }
+class test_case_counter : public test_tree_visitor {
+public:
+ // Constructor
+ test_case_counter() : p_count( 0 ) {}
- counter_t m_count;
+ BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count;
+private:
+ // test tree visitor interface
+ virtual void visit( test_case const& );
+ virtual bool test_suite_start( test_suite const& ts ) { return ts.p_enabled; }
};
// ************************************************************************** //
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk