Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64987 - trunk/boost/detail
From: bdawes_at_[hidden]
Date: 2010-08-24 14:57:40


Author: bemandawes
Date: 2010-08-24 14:57:38 EDT (Tue, 24 Aug 2010)
New Revision: 64987
URL: http://svn.boost.org/trac/boost/changeset/64987

Log:
Add BOOST_ASSERT that report_errors() has been called.
Text files modified:
   trunk/boost/detail/lightweight_test.hpp | 20 ++++++++++++++++++++
   1 files changed, 20 insertions(+), 0 deletions(-)

Modified: trunk/boost/detail/lightweight_test.hpp
==============================================================================
--- trunk/boost/detail/lightweight_test.hpp (original)
+++ trunk/boost/detail/lightweight_test.hpp 2010-08-24 14:57:38 EDT (Tue, 24 Aug 2010)
@@ -24,6 +24,7 @@
 //
 
 #include <boost/current_function.hpp>
+#include <boost/assert.hpp>
 #include <iostream>
 
 namespace boost
@@ -32,9 +33,26 @@
 namespace detail
 {
 
+struct report_errors_reminder
+{
+ bool called_report_errors_function;
+ report_errors_reminder() : called_report_errors_function(false) {}
+ ~report_errors_reminder()
+ {
+ BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
+ }
+};
+
+inline report_errors_reminder& report_errors_remind()
+{
+ static report_errors_reminder r;
+ return r;
+}
+
 inline int & test_errors()
 {
     static int x = 0;
+ report_errors_remind();
     return x;
 }
 
@@ -68,6 +86,8 @@
 
 inline int report_errors()
 {
+ detail::report_errors_remind().called_report_errors_function = true;
+
     int errors = detail::test_errors();
 
     if( errors == 0 )


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