diff --git a/include/boost/detail/lightweight_main.hpp b/include/boost/detail/lightweight_main.hpp new file mode 100644 index 0000000..1705309 --- /dev/null +++ b/include/boost/detail/lightweight_main.hpp @@ -0,0 +1,36 @@ +// boost/detail/lightweight_main.hpp -------------------------------------------------// + +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#include +#include + +//--------------------------------------------------------------------------------------// +// // +// exception reporting main() that calls cpp_main() // +// // +//--------------------------------------------------------------------------------------// + +int cpp_main(int argc, char* argv[]); + +int main(int argc, char* argv[]) +{ + try + { + return cpp_main(argc, argv); + } + + catch (const std::exception& ex) + { + std::cout + << "\nERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR\n" + << "\n****************************** std::exception *****************************\n" + << ex.what() + << "\n***************************************************************************\n" + << std::endl; + } + return 1; +} diff --git a/include/boost/detail/lightweight_test.hpp b/include/boost/detail/lightweight_test.hpp index ffa750d..8add322 100644 --- a/include/boost/detail/lightweight_test.hpp +++ b/include/boost/detail/lightweight_test.hpp @@ -24,6 +24,7 @@ // #include +#include #include namespace boost @@ -32,9 +33,26 @@ namespace boost 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 @@ template inline void test_eq_impl( char const * expr1, char co inline int report_errors() { + detail::report_errors_remind().called_report_errors_function = true; + int errors = detail::test_errors(); if( errors == 0 )