|
Boost-Commit : |
From: gennadiy.rozental_at_[hidden]
Date: 2008-07-09 01:05:43
Author: rogeeff
Date: 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
New Revision: 47258
URL: http://svn.boost.org/trac/boost/changeset/47258
Log:
Moves some config macros around
Introduces lazy_ostream - should speed u ptesting tools by avoiding output operation is many cases. Thanks to Jiri Palecek for an idea.
Removes misguided attempt at testing tools returning values.
Added:
trunk/boost/test/utils/lazy_ostream.hpp (contents, props changed)
Text files modified:
trunk/boost/test/detail/config.hpp | 33 ++++++-----
trunk/boost/test/detail/fwd_decl.hpp | 1
trunk/boost/test/impl/compiler_log_formatter.ipp | 9 +++
trunk/boost/test/impl/debug.ipp | 18 ++---
trunk/boost/test/impl/exception_safety.ipp | 5 -
trunk/boost/test/impl/interaction_based.ipp | 5 -
trunk/boost/test/impl/logged_expectations.ipp | 5 -
trunk/boost/test/impl/test_tools.ipp | 19 ++---
trunk/boost/test/impl/unit_test_log.ipp | 119 ++++++++++++++++++++++++++-------------
trunk/boost/test/output/compiler_log_formatter.hpp | 1
trunk/boost/test/test_tools.hpp | 44 +++-----------
trunk/boost/test/unit_test_log.hpp | 31 ++++++----
trunk/boost/test/unit_test_log_formatter.hpp | 1
trunk/boost/test/utils/basic_cstring/compare.hpp | 2
trunk/boost/test/utils/foreach.hpp | 24 --------
trunk/boost/test/utils/iterator/istream_line_iterator.hpp | 4 -
trunk/boost/test/utils/wrap_stringstream.hpp | 4 -
trunk/boost/test/utils/xml_printer.hpp | 12 ++--
18 files changed, 163 insertions(+), 174 deletions(-)
Modified: trunk/boost/test/detail/config.hpp
==============================================================================
--- trunk/boost/test/detail/config.hpp (original)
+++ trunk/boost/test/detail/config.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -19,12 +19,6 @@
#include <boost/config.hpp> // compilers workarounds
#include <boost/detail/workaround.hpp>
-#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
-# define BOOST_CLASSIC_IOSTREAMS
-#else
-# define BOOST_STANDARD_IOSTREAMS
-#endif
-
//____________________________________________________________________________//
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) || \
@@ -43,19 +37,20 @@
//____________________________________________________________________________//
-#if defined(BOOST_HAS_SIGACTION)
-# define BOOST_TEST_SUPPORT_TIMEOUT
+#if !defined(BOOST_NO_STD_LOCALE) && \
+ !BOOST_WORKAROUND(BOOST_MSVC, < 1310) && \
+ !defined(__MWERKS__)
+# define BOOST_TEST_USE_STD_LOCALE 1
#endif
//____________________________________________________________________________//
-#if BOOST_WORKAROUND(__BORLANDC__, <= 0x570) || \
- BOOST_WORKAROUND( __COMO__, <= 0x433 ) || \
- BOOST_WORKAROUND( __INTEL_COMPILER, <= 800 ) || \
- BOOST_WORKAROUND(__GNUC__, < 3) || \
- defined(__sgi) && _COMPILER_VERSION <= 730 || \
- BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \
- defined(__DECCXX) || \
+#if BOOST_WORKAROUND(__BORLANDC__, <= 0x570) || \
+ BOOST_WORKAROUND( __COMO__, <= 0x433 ) || \
+ BOOST_WORKAROUND( __INTEL_COMPILER, <= 800 ) || \
+ defined(__sgi) && _COMPILER_VERSION <= 730 || \
+ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \
+ defined(__DECCXX) || \
defined(__DMC__)
# define BOOST_TEST_NO_PROTECTED_USING
#endif
@@ -70,6 +65,14 @@
//____________________________________________________________________________//
+#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
+ !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
+ !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
+# define BOOST_TEST_SUPPORT_INTERACTION_TESTING 1
+#endif
+
+//____________________________________________________________________________//
+
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK)
# define BOOST_TEST_DYN_LINK
#endif
Modified: trunk/boost/test/detail/fwd_decl.hpp
==============================================================================
--- trunk/boost/test/detail/fwd_decl.hpp (original)
+++ trunk/boost/test/detail/fwd_decl.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -38,6 +38,7 @@
struct log_entry_data;
struct log_checkpoint_data;
+class lazy_ostream;
} // namespace unit_test
Modified: trunk/boost/test/impl/compiler_log_formatter.ipp
==============================================================================
--- trunk/boost/test/impl/compiler_log_formatter.ipp (original)
+++ trunk/boost/test/impl/compiler_log_formatter.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -20,6 +20,7 @@
#include <boost/test/unit_test_suite_impl.hpp>
#include <boost/test/framework.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
+#include <boost/test/utils/lazy_ostream.hpp>
// Boost
#include <boost/version.hpp>
@@ -167,6 +168,14 @@
//____________________________________________________________________________//
void
+compiler_log_formatter::log_entry_value( std::ostream& output, lazy_ostream const& value )
+{
+ output << value;
+}
+
+//____________________________________________________________________________//
+
+void
compiler_log_formatter::log_entry_finish( std::ostream& output )
{
output << std::endl;
Modified: trunk/boost/test/impl/debug.ipp
==============================================================================
--- trunk/boost/test/impl/debug.ipp (original)
+++ trunk/boost/test/impl/debug.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -724,19 +724,11 @@
// ************** console debugger setup ************** //
// ************************************************************************** //
-#if BOOST_WORKAROUND( BOOST_MSVC, <1300)
-std::string
-set_debugger( unit_test::const_string dbg_id )
-{
- dbg_starter s;
-#else
+#if defined(BOOST_UNIX_BASED_DEBUG) // ************************ UNIX
+
std::string
set_debugger( unit_test::const_string dbg_id, dbg_starter s )
{
-#endif
-
-#if defined(BOOST_UNIX_BASED_DEBUG) // ************************ UNIX
-
std::string old = s_info.p_dbg;
assign_op( s_info.p_dbg.value, dbg_id, 0 );
@@ -745,13 +737,17 @@
s_info.m_dbg_starter_reg[s_info.p_dbg] = s;
return old;
+}
#else // ***************************************************** default
+std::string
+set_debugger( unit_test::const_string, dbg_starter )
+{
return std::string();
+}
#endif
-}
//____________________________________________________________________________//
Modified: trunk/boost/test/impl/exception_safety.ipp
==============================================================================
--- trunk/boost/test/impl/exception_safety.ipp (original)
+++ trunk/boost/test/impl/exception_safety.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -18,10 +18,7 @@
// Boost.Test
#include <boost/test/detail/config.hpp>
-#if !BOOST_WORKAROUND(__GNUC__, < 3) && \
- !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
- !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
- !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/detail/unit_test_parameters.hpp>
Modified: trunk/boost/test/impl/interaction_based.ipp
==============================================================================
--- trunk/boost/test/impl/interaction_based.ipp (original)
+++ trunk/boost/test/impl/interaction_based.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -18,10 +18,7 @@
// Boost.Test
#include <boost/test/detail/config.hpp>
-#if !BOOST_WORKAROUND(__GNUC__, < 3) && \
- !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
- !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
- !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
// Boost.Test
#include <boost/test/detail/config.hpp>
Modified: trunk/boost/test/impl/logged_expectations.ipp
==============================================================================
--- trunk/boost/test/impl/logged_expectations.ipp (original)
+++ trunk/boost/test/impl/logged_expectations.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -18,10 +18,7 @@
// Boost.Test
#include <boost/test/detail/config.hpp>
-#if !BOOST_WORKAROUND(__GNUC__, < 3) && \
- !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
- !BOOST_WORKAROUND(BOOST_MSVC, <1310) && \
- !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x530))
+#if BOOST_TEST_SUPPORT_INTERACTION_TESTING
#include <boost/test/detail/global_typedef.hpp>
Modified: trunk/boost/test/impl/test_tools.ipp
==============================================================================
--- trunk/boost/test/impl/test_tools.ipp (original)
+++ trunk/boost/test/impl/test_tools.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -33,9 +33,7 @@
#include <cctype>
#include <cwchar>
#include <stdexcept>
-#ifdef BOOST_STANDARD_IOSTREAMS
#include <ios>
-#endif
// !! should we use #include <cstdarg>
#include <stdarg.h>
@@ -62,7 +60,7 @@
// ************************************************************************** //
bool
-check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
+check_impl( predicate_result const& pr, ::boost::unit_test::lazy_ostream const& check_descr,
const_string file_name, std::size_t line_num,
tool_level tl, check_type ct,
std::size_t num_of_args, ... )
@@ -107,7 +105,7 @@
switch( ct ) {
case CHECK_PRED:
unit_test_log << unit_test::log::begin( file_name, line_num )
- << ll << prefix << check_descr.str() << suffix;
+ << ll << prefix << check_descr << suffix;
if( !pr.has_empty_message() )
unit_test_log << ". " << pr.message();
@@ -119,9 +117,9 @@
unit_test_log << unit_test::log::begin( file_name, line_num ) << ll;
if( tl == PASS )
- unit_test_log << prefix << "'" << check_descr.str() << "'" << suffix;
+ unit_test_log << prefix << "'" << check_descr << "'" << suffix;
else
- unit_test_log << check_descr.str();
+ unit_test_log << check_descr;
if( !pr.has_empty_message() )
unit_test_log << ". " << pr.message();
@@ -216,7 +214,7 @@
case CHECK_PRED_WITH_ARGS: {
unit_test_log << unit_test::log::begin( file_name, line_num )
- << ll << prefix << check_descr.str();
+ << ll << prefix << check_descr;
// print predicate call description
{
@@ -367,8 +365,7 @@
ostr << '\'' << t << '\'';
else
ostr << std::hex
- // showbase is only available for new style streams:
-#ifndef BOOST_NO_STD_LOCALE
+#if BOOST_TEST_USE_STD_LOCALE
<< std::showbase
#else
<< "0x"
@@ -383,12 +380,12 @@
{
ostr << std::hex
// showbase is only available for new style streams:
-#ifndef BOOST_NO_STD_LOCALE
+#if BOOST_TEST_USE_STD_LOCALE
<< std::showbase
#else
<< "0x"
#endif
- << (int)t;
+ << (int)t;
}
//____________________________________________________________________________//
Modified: trunk/boost/test/impl/unit_test_log.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_log.ipp (original)
+++ trunk/boost/test/impl/unit_test_log.ipp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -50,15 +50,22 @@
namespace ut_detail {
-entry_value_collector
-entry_value_collector::operator<<( const_string v )
+entry_value_collector const&
+entry_value_collector::operator<<( lazy_ostream const& v ) const
{
unit_test_log << v;
- m_last = false;
+ return *this;
+}
- entry_value_collector res;
- return res;
+//____________________________________________________________________________//
+
+entry_value_collector const&
+entry_value_collector::operator<<( const_string v ) const
+{
+ unit_test_log << v;
+
+ return *this;
}
//____________________________________________________________________________//
@@ -303,8 +310,49 @@
{
*this << l;
- ut_detail::entry_value_collector res;
- return res;
+ return ut_detail::entry_value_collector();
+}
+
+//____________________________________________________________________________//
+
+bool
+unit_test_log_t::log_entry_start()
+{
+ if( s_log_impl().m_entry_in_progress )
+ return true;
+
+ switch( s_log_impl().m_entry_data.m_level ) {
+ case log_successful_tests:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_INFO );
+ break;
+ case log_messages:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_MESSAGE );
+ break;
+ case log_warnings:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_WARNING );
+ break;
+ case log_all_errors:
+ case log_cpp_exception_errors:
+ case log_system_errors:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_ERROR );
+ break;
+ case log_fatal_errors:
+ s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
+ unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR );
+ break;
+ case log_nothing:
+ case log_test_units:
+ case invalid_log_level:
+ return false;
+ }
+
+ s_log_impl().m_entry_in_progress = true;
+
+ return true;
}
//____________________________________________________________________________//
@@ -312,42 +360,19 @@
unit_test_log_t&
unit_test_log_t::operator<<( const_string value )
{
- if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() ) {
- if( !s_log_impl().m_entry_in_progress ) {
- s_log_impl().m_entry_in_progress = true;
-
- switch( s_log_impl().m_entry_data.m_level ) {
- case log_successful_tests:
- s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
- unit_test_log_formatter::BOOST_UTL_ET_INFO );
- break;
- case log_messages:
- s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
- unit_test_log_formatter::BOOST_UTL_ET_MESSAGE );
- break;
- case log_warnings:
- s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
- unit_test_log_formatter::BOOST_UTL_ET_WARNING );
- break;
- case log_all_errors:
- case log_cpp_exception_errors:
- case log_system_errors:
- s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
- unit_test_log_formatter::BOOST_UTL_ET_ERROR );
- break;
- case log_fatal_errors:
- s_log_impl().m_log_formatter->log_entry_start( s_log_impl().stream(), s_log_impl().m_entry_data,
- unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR );
- break;
- case log_nothing:
- case log_test_units:
- case invalid_log_level:
- return *this;
- }
- }
+ if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() )
+ s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value );
+ return *this;
+}
+
+//____________________________________________________________________________//
+
+unit_test_log_t&
+unit_test_log_t::operator<<( lazy_ostream const& value )
+{
+ if( s_log_impl().m_entry_data.m_level >= s_log_impl().m_threshold_level && !value.empty() && log_entry_start() )
s_log_impl().m_log_formatter->log_entry_value( s_log_impl().stream(), value );
- }
return *this;
}
@@ -399,6 +424,18 @@
//____________________________________________________________________________//
+// ************************************************************************** //
+// ************** unit_test_log_formatter ************** //
+// ************************************************************************** //
+
+void
+unit_test_log_formatter::log_entry_value( std::ostream& ostr, lazy_ostream const& value )
+{
+ log_entry_value( ostr, (wrap_stringstream().ref() << value).str() );
+}
+
+//____________________________________________________________________________//
+
} // namespace unit_test
} // namespace boost
Modified: trunk/boost/test/output/compiler_log_formatter.hpp
==============================================================================
--- trunk/boost/test/output/compiler_log_formatter.hpp (original)
+++ trunk/boost/test/output/compiler_log_formatter.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -48,6 +48,7 @@
void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let );
void log_entry_value( std::ostream&, const_string value );
+ void log_entry_value( std::ostream&, lazy_ostream const& value );
void log_entry_finish( std::ostream& );
protected:
Modified: trunk/boost/test/test_tools.hpp
==============================================================================
--- trunk/boost/test/test_tools.hpp (original)
+++ trunk/boost/test/test_tools.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -25,6 +25,7 @@
#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>
@@ -70,51 +71,29 @@
// CT - check type
// ARGS - arguments list
-#define BOOST_TEST_TOOL_IMPL( func, P, check_descr, TL, CT ) \
- ::boost::test_tools::tt_detail::func( \
- P, \
- ::boost::wrap_stringstream().ref() << check_descr, \
- BOOST_TEST_L(__FILE__), \
- (std::size_t)__LINE__, \
- ::boost::test_tools::tt_detail::TL, \
- ::boost::test_tools::tt_detail::CT \
+#define BOOST_TEST_TOOL_IMPL( func, P, check_descr, TL, CT ) \
+ ::boost::test_tools::tt_detail::func( \
+ P, \
+ ::boost::unit_test::lazy_ostream::instance() << check_descr, \
+ BOOST_TEST_L(__FILE__), \
+ (std::size_t)__LINE__, \
+ ::boost::test_tools::tt_detail::TL, \
+ ::boost::test_tools::tt_detail::CT \
/**/
//____________________________________________________________________________//
-#if defined(__GNUC__)
-# define BOOST_TEST_TOOLS_RETURN_VALUE
-#endif
-
-#ifdef BOOST_TEST_TOOLS_RETURN_VALUE
-#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \
-({ \
- BOOST_TEST_PASSPOINT(); \
- BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
-}) \
-/**/
-#else
#define BOOST_CHECK_IMPL( P, check_descr, TL, CT ) \
do { \
BOOST_TEST_PASSPOINT(); \
BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
} while( ::boost::test_tools::dummy_cond ) \
/**/
-#endif
//____________________________________________________________________________//
#define BOOST_TEST_PASS_ARG_INFO( r, data, arg ) , arg, BOOST_STRINGIZE( arg )
-#ifdef BOOST_TEST_TOOLS_RETURN_VALUE
-#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \
-({ \
- BOOST_TEST_PASSPOINT(); \
- BOOST_TEST_TOOL_IMPL( check_frwd, P, check_descr, TL, CT ) \
- BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \
-}) \
-/**/
-#else
#define BOOST_CHECK_WITH_ARGS_IMPL( P, check_descr, TL, CT, ARGS ) \
do { \
BOOST_TEST_PASSPOINT(); \
@@ -122,7 +101,6 @@
BOOST_PP_SEQ_FOR_EACH( BOOST_TEST_PASS_ARG_INFO, '_', ARGS ) ); \
} while( ::boost::test_tools::dummy_cond ) \
/**/
-#endif
//____________________________________________________________________________//
@@ -490,7 +468,7 @@
// ************************************************************************** //
BOOST_TEST_DECL
-bool check_impl( predicate_result const& pr, wrap_stringstream& check_descr,
+bool check_impl( predicate_result const& pr, ::boost::unit_test::lazy_ostream const& check_descr,
const_string file_name, std::size_t line_num,
tool_level tl, check_type ct,
std::size_t num_args, ... );
@@ -516,7 +494,7 @@
template<typename Pred \
BOOST_PP_REPEAT_ ## z( BOOST_PP_ADD( n, 1 ), TEMPL_PARAMS, _ )> \
inline bool \
-check_frwd( Pred P, wrap_stringstream& check_descr, \
+check_frwd( Pred P, unit_test::lazy_ostream const& check_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, _ ) \
Modified: trunk/boost/test/unit_test_log.hpp
==============================================================================
--- trunk/boost/test/unit_test_log.hpp (original)
+++ trunk/boost/test/unit_test_log.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -26,6 +26,7 @@
#include <boost/test/utils/wrap_stringstream.hpp>
#include <boost/test/utils/trivial_singleton.hpp>
+#include <boost/test/utils/lazy_ostream.hpp>
// Boost
#include <boost/utility.hpp>
@@ -71,15 +72,16 @@
public:
// Constructors
entry_value_collector() : m_last( true ) {}
- entry_value_collector( entry_value_collector& rhs ) : m_last( true ) { rhs.m_last = false; }
+ entry_value_collector( entry_value_collector const& rhs ) : m_last( true ) { rhs.m_last = false; }
~entry_value_collector();
// collection interface
- entry_value_collector operator<<( const_string );
+ entry_value_collector const& operator<<( lazy_ostream const& ) const;
+ entry_value_collector const& operator<<( const_string ) const;
private:
// Data members
- bool m_last;
+ mutable bool m_last;
};
} // namespace ut_detail
@@ -119,10 +121,13 @@
unit_test_log_t& operator<<( log::end const& ); // end entry
unit_test_log_t& operator<<( log_level ); // set entry level
unit_test_log_t& operator<<( const_string ); // log entry value
+ unit_test_log_t& operator<<( lazy_ostream const& ); // log entry value
ut_detail::entry_value_collector operator()( log_level ); // initiate entry collection
private:
+ bool log_entry_start();
+
BOOST_TEST_SINGLETON_CONS( unit_test_log_t );
}; // unit_test_log_t
@@ -144,24 +149,24 @@
#define BOOST_TEST_MESSAGE( M ) \
BOOST_TEST_LOG_ENTRY( ::boost::unit_test::log_messages ) \
- << (boost::wrap_stringstream().ref() << M).str() \
+ << (::boost::unit_test::lazy_ostream::instance() << M) \
/**/
//____________________________________________________________________________//
-#define BOOST_TEST_PASSPOINT() \
- ::boost::unit_test::unit_test_log.set_checkpoint( \
- BOOST_TEST_L(__FILE__), \
- (std::size_t)__LINE__ ) \
+#define BOOST_TEST_PASSPOINT() \
+ ::boost::unit_test::unit_test_log.set_checkpoint( \
+ BOOST_TEST_L(__FILE__), \
+ (std::size_t)__LINE__ ) \
/**/
//____________________________________________________________________________//
-#define BOOST_TEST_CHECKPOINT( M ) \
- ::boost::unit_test::unit_test_log.set_checkpoint( \
- BOOST_TEST_L(__FILE__), \
- (std::size_t)__LINE__, \
- (boost::wrap_stringstream().ref() << M).str() ) \
+#define BOOST_TEST_CHECKPOINT( M ) \
+ ::boost::unit_test::unit_test_log.set_checkpoint( \
+ BOOST_TEST_L(__FILE__), \
+ (std::size_t)__LINE__, \
+ (::boost::wrap_stringstream().ref() << M).str() ) \
/**/
//____________________________________________________________________________//
Modified: trunk/boost/test/unit_test_log_formatter.hpp
==============================================================================
--- trunk/boost/test/unit_test_log_formatter.hpp (original)
+++ trunk/boost/test/unit_test_log_formatter.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -100,6 +100,7 @@
virtual void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) = 0;
virtual void log_entry_value( std::ostream&, const_string value ) = 0;
+ virtual void log_entry_value( std::ostream&, lazy_ostream const& value ); // there is a default impl
virtual void log_entry_finish( std::ostream& ) = 0;
};
Modified: trunk/boost/test/utils/basic_cstring/compare.hpp
==============================================================================
--- trunk/boost/test/utils/basic_cstring/compare.hpp (original)
+++ trunk/boost/test/utils/basic_cstring/compare.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -26,7 +26,7 @@
//____________________________________________________________________________//
-# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) && !BOOST_WORKAROUND(__GNUC__, < 3)
+# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570)
namespace std { using ::toupper; }
# endif
Modified: trunk/boost/test/utils/foreach.hpp
==============================================================================
--- trunk/boost/test/utils/foreach.hpp (original)
+++ trunk/boost/test/utils/foreach.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -203,10 +203,6 @@
// ************** BOOST_TEST_FOREACH ************** //
// ************************************************************************** //
-#if BOOST_WORKAROUND(__GNUC__, < 3)
-#define BOOST_TEST_FE_MULTISTATEMENT
-#endif
-
#define BOOST_TEST_FE_ANY ::boost::unit_test::for_each::static_any_t
#define BOOST_TEST_FE_IS_CONST( COL ) ::boost::unit_test::for_each::is_const_coll( COL )
@@ -258,8 +254,6 @@
#define BOOST_TEST_FE_END_VAR BOOST_JOIN( _fe_end_, BOOST_TEST_LINE_NUM )
#define BOOST_TEST_FE_CON_VAR BOOST_JOIN( _fe_con_, BOOST_TEST_LINE_NUM )
-#ifndef BOOST_TEST_FE_MULTISTATEMENT
-
#define BOOST_TEST_FOREACH( RefType, var, COL ) \
if( BOOST_TEST_FE_ANY BOOST_TEST_FE_CUR_VAR = BOOST_TEST_FE_BEG( COL ) ) {} else \
if( BOOST_TEST_FE_ANY BOOST_TEST_FE_END_VAR = BOOST_TEST_FE_END( COL ) ) {} else \
@@ -272,24 +266,6 @@
!BOOST_TEST_FE_CON_VAR; BOOST_TEST_FE_CON_VAR = true ) \
/**/
-#else
-
-#define BOOST_TEST_FOREACH( RefType, var, COL ) \
-BOOST_TEST_FE_ANY BOOST_TEST_FE_CUR_VAR = BOOST_TEST_FE_BEG( COL ), \
- BOOST_TEST_FE_END_VAR = BOOST_TEST_FE_END( COL ); \
- \
-for( bool BOOST_TEST_FE_CON_VAR = true; BOOST_TEST_FE_CON_VAR; ) \
-for( ; \
- BOOST_TEST_FE_CON_VAR && (BOOST_TEST_FE_CON_VAR = !BOOST_TEST_FE_DONE( COL )); \
- BOOST_TEST_FE_CON_VAR ? BOOST_TEST_FE_NEXT( COL ) : BOOST_FOREACH_NOOP( COL )) \
- \
- if( (BOOST_TEST_FE_CON_VAR = false, false) ) {} else \
- for( RefType var = BOOST_TEST_FE_DEREF( COL, RefType ); \
- !BOOST_TEST_FE_CON_VAR; BOOST_TEST_FE_CON_VAR = true ) \
-/**/
-
-#endif
-
//____________________________________________________________________________//
} // namespace for_each
Modified: trunk/boost/test/utils/iterator/istream_line_iterator.hpp
==============================================================================
--- trunk/boost/test/utils/iterator/istream_line_iterator.hpp (original)
+++ trunk/boost/test/utils/iterator/istream_line_iterator.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -59,11 +59,7 @@
}
explicit basic_istream_line_iterator( istream_type& input )
: m_input_stream( &input )
-#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
- , m_delimeter( '\n' )
-#else
, m_delimeter( input.widen( '\n' ) )
-#endif
{
this->init();
}
Added: trunk/boost/test/utils/lazy_ostream.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/test/utils/lazy_ostream.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -0,0 +1,114 @@
+// (C) Copyright Gennadiy Rozental 2008.
+// 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 : contains definition for all test tools in test toolbox
+// ***************************************************************************
+
+#ifndef BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
+#define BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
+
+// Boost.Test
+#include <boost/test/detail/config.hpp>
+
+// STL
+#include <iosfwd>
+
+#include <boost/test/detail/suppress_warnings.hpp>
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** lazy_ostream ************** //
+// ************************************************************************** //
+
+namespace boost {
+
+namespace unit_test {
+
+class lazy_ostream {
+public:
+ static lazy_ostream& instance() { static lazy_ostream inst; return inst; }
+
+ friend std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ) { return o( ostr ); }
+
+ // access method
+ bool empty() const { return m_empty; }
+
+ // actual printing interface; to be accessed only by this class and children
+ virtual std::ostream& operator()( std::ostream& ostr ) const { return ostr; }
+protected:
+ explicit lazy_ostream( bool empty = true ) : m_empty( empty ) {}
+
+ // protected destructor to make sure right one is called
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
+public:
+#endif
+ BOOST_TEST_PROTECTED_VIRTUAL ~lazy_ostream() {}
+
+private:
+ // Data members
+ bool m_empty;
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+class lazy_ostream_impl : public lazy_ostream {
+public:
+ lazy_ostream_impl( lazy_ostream const& prev, T value )
+ : lazy_ostream( false )
+ , m_prev( prev )
+ , m_value( value )
+ {}
+private:
+ virtual std::ostream& operator()( std::ostream& ostr ) const
+ {
+ return m_prev(ostr) << m_value;
+ }
+
+ // Data members
+ lazy_ostream const& m_prev;
+ T m_value;
+};
+
+//____________________________________________________________________________//
+
+template<typename T>
+inline lazy_ostream_impl<T const&>
+operator<<( lazy_ostream const& prev, T const& v )
+{
+ return lazy_ostream_impl<T const&>( prev, v );
+}
+
+//____________________________________________________________________________//
+
+#if BOOST_TEST_USE_STD_LOCALE
+
+template<typename R,typename S>
+inline lazy_ostream_impl<R& (BOOST_TEST_CALL_DECL *)(S&)>
+operator<<( lazy_ostream const& prev, R& (BOOST_TEST_CALL_DECL *man)(S&) )
+{
+ return lazy_ostream_impl<R& (BOOST_TEST_CALL_DECL *)(S&)>( prev, man );
+}
+
+//____________________________________________________________________________//
+
+#endif
+
+} // namespace unit_test
+
+} // namespace boost
+
+//____________________________________________________________________________//
+
+#include <boost/test/detail/enable_warnings.hpp>
+
+#endif // BOOST_TEST_LAZY_OSTREAM_HPP_070708GER
Modified: trunk/boost/test/utils/wrap_stringstream.hpp
==============================================================================
--- trunk/boost/test/utils/wrap_stringstream.hpp (original)
+++ trunk/boost/test/utils/wrap_stringstream.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -114,9 +114,7 @@
//____________________________________________________________________________//
-#if !defined(BOOST_NO_STD_LOCALE) && \
- (!defined(BOOST_MSVC) || BOOST_WORKAROUND(BOOST_MSVC, >= 1310)) && \
- !defined(__MWERKS__) && !BOOST_WORKAROUND(__GNUC__, < 3)
+#if BOOST_TEST_USE_STD_LOCALE
template <typename CharT>
inline basic_wrap_stringstream<CharT>&
Modified: trunk/boost/test/utils/xml_printer.hpp
==============================================================================
--- trunk/boost/test/utils/xml_printer.hpp (original)
+++ trunk/boost/test/utils/xml_printer.hpp 2008-07-09 01:05:40 EDT (Wed, 09 Jul 2008)
@@ -67,7 +67,7 @@
inline void
print_escaped( std::ostream& where_to, std::string const& value )
{
- print_escaped( where_to, const_string( value ) );
+ print_escaped( where_to, const_string( value ) );
}
//____________________________________________________________________________//
@@ -76,7 +76,7 @@
inline void
print_escaped( std::ostream& where_to, T const& value )
{
- where_to << value;
+ where_to << value;
}
//____________________________________________________________________________//
@@ -87,11 +87,11 @@
inline std::ostream&
operator<<( custom_printer<attr_value> const& p, T const& value )
{
- *p << "=\"";
- print_escaped( *p, value );
- *p << '"';
+ *p << "=\"";
+ print_escaped( *p, value );
+ *p << '"';
- return *p;
+ return *p;
}
//____________________________________________________________________________//
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