From c71eb0e479c8c1cd1277407e2d386e8965aec1bc Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 4 Sep 2018 16:55:35 -0400 Subject: [PATCH 1/2] Abort instead of assert if report_errors() not called --- include/boost/core/lightweight_test.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 5c4547a..b8f7d88 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -23,10 +23,10 @@ // #include -#include #include #include #include +#include #include #include @@ -45,11 +45,14 @@ namespace detail class test_result { public: test_result() - : report_errors_called_(false) + : report_(false) , errors_(0) { } ~test_result() { - BOOST_ASSERT(report_errors_called_); + if (!report_) { + BOOST_LIGHTWEIGHT_TEST_OSTREAM << "report_errors() not called" << std::endl; + std::abort(); + } } void error() { @@ -57,12 +60,12 @@ public: } int done() { - report_errors_called_ = true; + report_ = true; return errors_; } private: - bool report_errors_called_; + bool report_; int errors_; }; From 30c006ac82a4daf9ca9f86f028a71473cf4b2d7c Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 4 Sep 2018 19:34:30 -0400 Subject: [PATCH 2/2] Call test_results() in BOOST_TEST() --- include/boost/core/lightweight_test.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index b8f7d88..e90ba56 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -385,7 +385,7 @@ inline int report_errors() } // namespace boost -#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)) +#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)) #define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr)) #define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )