Boost logo

Boost-Commit :

From: dwalker07_at_[hidden]
Date: 2008-06-30 13:33:47


Author: dlwalker
Date: 2008-06-30 13:33:47 EDT (Mon, 30 Jun 2008)
New Revision: 46924
URL: http://svn.boost.org/trac/boost/changeset/46924

Log:
Added support for an Xcode-compatible logging format during unit tests
Text files modified:
   sandbox/md5/libs/coding/test/md5_digest_test.cpp | 38 ++++++++++++++++++++++++++++++++++++++
   1 files changed, 38 insertions(+), 0 deletions(-)

Modified: sandbox/md5/libs/coding/test/md5_digest_test.cpp
==============================================================================
--- sandbox/md5/libs/coding/test/md5_digest_test.cpp (original)
+++ sandbox/md5/libs/coding/test/md5_digest_test.cpp 2008-06-30 13:33:47 EDT (Mon, 30 Jun 2008)
@@ -13,12 +13,15 @@
 
 #include <boost/lexical_cast.hpp> // for boost::lexical_cast
 #include <boost/test/unit_test.hpp> // unit testing framework
+#include <boost/test/output/compiler_log_formatter.hpp> // for new formatter
 
 #include <cstddef> // for std::size_t
 #include <cstdio> // for EOF
 #include <cwchar> // for WEOF, std::wint_t
 #include <iomanip> // for std::setfill, setw
 #include <ios> // for std::left, uppercase
+#include <memory> // for std::auto_ptr [for xcode_config]
+#include <ostream> // for std::ostream [for xcode_log_formatter]
 #include <sstream> // for std::[w](o|i)stringstream
 #include <string> // for std::string, wstring
 
@@ -33,6 +36,41 @@
 namespace
 {
 
+#ifdef __APPLE_CC__
+/* Xcode-compatible logging format, idea by Richard Dingwall at
+ <http://richarddingwall.name/2008/06/01/using-the-boost-unit-test-framework-
+ with-xcode-3/>.
+*/
+class xcode_log_formatter
+ : public boost::unit_test::output::compiler_log_formatter
+{
+protected:
+ virtual void print_prefix( std::ostream &o, boost::unit_test::const_string
+ file, std::size_t line )
+ {
+ o << file << ':' << line << ": ";
+ }
+
+}; // xcode_log_formatter
+
+class xcode_config
+{
+public:
+ xcode_config()
+ {
+ std::auto_ptr<xcode_log_formatter> p( new xcode_log_formatter );
+
+ boost::unit_test::unit_test_log.set_formatter( p.get() );
+ p.release();
+ }
+
+ ~xcode_config() {}
+
+}; // xcode_config
+
+BOOST_GLOBAL_FIXTURE(xcode_config);
+#endif
+
 // Sample MD5 message digest values
 md5_digest const md5_initial = { {0x67452301ul, 0xEFCDAB89ul, 0x98BADCFEul,
  0x10325476ul} }; // from RFC 1321, section 3.3


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