|
Boost-Commit : |
From: gennadiy.rozental_at_[hidden]
Date: 2007-10-22 02:36:51
Author: rogeeff
Date: 2007-10-22 02:36:50 EDT (Mon, 22 Oct 2007)
New Revision: 40276
URL: http://svn.boost.org/trac/boost/changeset/40276
Log:
framework::is_initialized introduced to catch framework misuse errors
Message report too few failed assertions updated
New message added to report no assertion occurred in a test case
test_suite::remove interface is added to allow remove test units from the test suite if necessary
Text files modified:
trunk/boost/test/framework.hpp | 1 +
trunk/boost/test/impl/framework.ipp | 12 ++++++++++++
trunk/boost/test/impl/results_collector.ipp | 6 +++++-
trunk/boost/test/impl/test_tools.ipp | 4 ++++
trunk/boost/test/impl/unit_test_suite.ipp | 11 +++++++++++
trunk/boost/test/unit_test_suite_impl.hpp | 3 ++-
6 files changed, 35 insertions(+), 2 deletions(-)
Modified: trunk/boost/test/framework.hpp
==============================================================================
--- trunk/boost/test/framework.hpp (original)
+++ trunk/boost/test/framework.hpp 2007-10-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -49,6 +49,7 @@
// initialization
BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] );
+BOOST_TEST_DECL bool is_initialized();
// mutation access methods
BOOST_TEST_DECL void register_test_unit( test_case* tc );
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2007-10-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -114,6 +114,7 @@
, m_curr_test_case( INV_TEST_UNIT_ID )
, m_next_test_case_id( MIN_TEST_CASE_ID )
, m_next_test_suite_id( MIN_TEST_SUITE_ID )
+ , m_is_initialized( false )
, m_test_in_progress( false )
{}
@@ -202,6 +203,7 @@
test_unit_id m_next_test_case_id;
test_unit_id m_next_test_suite_id;
+ bool m_is_initialized;
bool m_test_in_progress;
observer_store m_observers;
@@ -257,6 +259,16 @@
catch( execution_exception const& ex ) {
throw setup_error( ex.what() );
}
+
+ s_frk_impl().m_is_initialized = true;
+}
+
+//____________________________________________________________________________//
+
+bool
+is_initialized()
+{
+ return s_frk_impl().m_is_initialized;
}
//____________________________________________________________________________//
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-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -213,7 +213,11 @@
bool num_failures_match = tr.p_aborted || tr.p_assertions_failed >= tr.p_expected_failures;
if( !num_failures_match )
- BOOST_TEST_MESSAGE( "Test case has less failures then expected" );
+ 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" );
}
}
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-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -32,6 +32,7 @@
#include <cstring>
#include <cctype>
#include <cwchar>
+#include <stdexcept>
#ifdef BOOST_STANDARD_IOSTREAMS
#include <ios>
#endif
@@ -68,6 +69,9 @@
{
using namespace unit_test;
+ if( !framework::is_initialized() )
+ throw std::runtime_error( "can't use testing tools before framework is initialized" );
+
if( !!pr )
tl = PASS;
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-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -155,6 +155,17 @@
//____________________________________________________________________________//
+void
+test_suite::remove( test_unit_id id )
+{
+ std::vector<test_unit_id>::iterator it = std::find( m_members.begin(), m_members.begin(), id );
+
+ if( it != m_members.end() )
+ m_members.erase( it );
+}
+
+//____________________________________________________________________________//
+
test_unit_id
test_suite::get( const_string tu_name ) const
{
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-22 02:36:50 EDT (Mon, 22 Oct 2007)
@@ -125,10 +125,11 @@
// test unit list management
void add( test_unit* tu, counter_t expected_failures = 0, unsigned timeout = 0 );
void add( test_unit_generator const& gen, unsigned timeout = 0 );
+ void remove( test_unit_id id );
// access methods
test_unit_id get( const_string tu_name ) const;
- size_t size() const { return m_members.size(); }
+ std::size_t size() const { return m_members.size(); }
protected:
friend BOOST_TEST_DECL
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