Boost logo

Boost-Commit :

From: gennadiy.rozental_at_[hidden]
Date: 2008-07-24 22:17:07


Author: rogeeff
Date: 2008-07-24 22:17:07 EDT (Thu, 24 Jul 2008)
New Revision: 47772
URL: http://svn.boost.org/trac/boost/changeset/47772

Log:
move print_log_value to the test_tools namespace
Text files modified:
   trunk/boost/test/impl/test_tools.ipp | 104 ++++++++++++++++++++--------------------
   trunk/boost/test/test_tools.hpp | 76 +++++++++++++++-------------
   2 files changed, 93 insertions(+), 87 deletions(-)

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-24 22:17:07 EDT (Thu, 24 Jul 2008)
@@ -53,6 +53,58 @@
 
 namespace test_tools {
 
+// ************************************************************************** //
+// ************** print_log_value ************** //
+// ************************************************************************** //
+
+void
+print_log_value<char>::operator()( std::ostream& ostr, char t )
+{
+ if( (std::isprint)( (unsigned char)t ) )
+ ostr << '\'' << t << '\'';
+ else
+ ostr << std::hex
+#if BOOST_TEST_USE_STD_LOCALE
+ << std::showbase
+#else
+ << "0x"
+#endif
+ << (int)t;
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<unsigned char>::operator()( std::ostream& ostr, unsigned char t )
+{
+ ostr << std::hex
+ // showbase is only available for new style streams:
+#if BOOST_TEST_USE_STD_LOCALE
+ << std::showbase
+#else
+ << "0x"
+#endif
+ << (int)t;
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<char const*>::operator()( std::ostream& ostr, char const* t )
+{
+ ostr << ( t ? t : "null string" );
+}
+
+//____________________________________________________________________________//
+
+void
+print_log_value<wchar_t const*>::operator()( std::ostream& ostr, wchar_t const* t )
+{
+ ostr << ( t ? t : L"null string" );
+}
+
+//____________________________________________________________________________//
+
 namespace tt_detail {
 
 // ************************************************************************** //
@@ -354,58 +406,6 @@
 
 //____________________________________________________________________________//
 
-// ************************************************************************** //
-// ************** log print helper ************** //
-// ************************************************************************** //
-
-void
-print_log_value<char>::operator()( std::ostream& ostr, char t )
-{
- if( (std::isprint)( (unsigned char)t ) )
- ostr << '\'' << t << '\'';
- else
- ostr << std::hex
-#if BOOST_TEST_USE_STD_LOCALE
- << std::showbase
-#else
- << "0x"
-#endif
- << (int)t;
-}
-
-//____________________________________________________________________________//
-
-void
-print_log_value<unsigned char>::operator()( std::ostream& ostr, unsigned char t )
-{
- ostr << std::hex
- // showbase is only available for new style streams:
-#if BOOST_TEST_USE_STD_LOCALE
- << std::showbase
-#else
- << "0x"
-#endif
- << (int)t;
-}
-
-//____________________________________________________________________________//
-
-void
-print_log_value<char const*>::operator()( std::ostream& ostr, char const* t )
-{
- ostr << ( t ? t : "null string" );
-}
-
-//____________________________________________________________________________//
-
-void
-print_log_value<wchar_t const*>::operator()( std::ostream& ostr, wchar_t const* t )
-{
- ostr << ( t ? t : L"null string" );
-}
-
-//____________________________________________________________________________//
-
 } // namespace tt_detail
 
 // ************************************************************************** //

Modified: trunk/boost/test/test_tools.hpp
==============================================================================
--- trunk/boost/test/test_tools.hpp (original)
+++ trunk/boost/test/test_tools.hpp 2008-07-24 22:17:07 EDT (Thu, 24 Jul 2008)
@@ -306,35 +306,8 @@
 
 namespace { bool const dummy_cond = false; }
 
-namespace tt_detail {
-
 // ************************************************************************** //
-// ************** tools classification ************** //
-// ************************************************************************** //
-
-enum check_type {
- CHECK_PRED,
- CHECK_MSG,
- CHECK_EQUAL,
- CHECK_NE,
- CHECK_LT,
- CHECK_LE,
- CHECK_GT,
- CHECK_GE,
- CHECK_CLOSE,
- CHECK_CLOSE_FRACTION,
- CHECK_SMALL,
- CHECK_BITWISE_EQUAL,
- CHECK_PRED_WITH_ARGS,
- CHECK_EQUAL_COLL
-};
-
-enum tool_level {
- WARN, CHECK, REQUIRE, PASS
-};
-
-// ************************************************************************** //
-// ************** log print helper ************** //
+// ************** print_log_value ************** //
 // ************************************************************************** //
 
 template<typename T>
@@ -362,13 +335,13 @@
 
 //____________________________________________________________________________//
 
-#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
-namespace boost { namespace test_tools { namespace tt_detail { \
-template<> \
-struct print_log_value<the_type > { \
- void operator()( std::ostream&, the_type const& ) {} \
-}; \
-}}} \
+#define BOOST_TEST_DONT_PRINT_LOG_VALUE( the_type ) \
+namespace boost { namespace test_tools { \
+template<> \
+struct print_log_value<the_type > { \
+ void operator()( std::ostream&, the_type const& ) {} \
+}; \
+}} \
 /**/
 
 //____________________________________________________________________________//
@@ -423,6 +396,39 @@
 
 //____________________________________________________________________________//
 
+namespace tt_detail {
+
+// ************************************************************************** //
+// ************** tools classification ************** //
+// ************************************************************************** //
+
+enum check_type {
+ CHECK_PRED,
+ CHECK_MSG,
+ CHECK_EQUAL,
+ CHECK_NE,
+ CHECK_LT,
+ CHECK_LE,
+ CHECK_GT,
+ CHECK_GE,
+ CHECK_CLOSE,
+ CHECK_CLOSE_FRACTION,
+ CHECK_SMALL,
+ CHECK_BITWISE_EQUAL,
+ CHECK_PRED_WITH_ARGS,
+ CHECK_EQUAL_COLL
+};
+
+enum tool_level {
+ WARN, CHECK, REQUIRE, PASS
+};
+
+// ************************************************************************** //
+// ************** print_helper ************** //
+// ************************************************************************** //
+// Adds level of indirection to the output operation, allowing us to customize
+// it for types that do not support operator << directly or for any other reason
+
 template<typename T>
 struct print_helper_t {
     explicit print_helper_t( T const& t ) : m_t( t ) {}


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