Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:09:21

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// @brief Deprecated implementation of simple minimal testing
0010 /// @deprecated
0011 /// To convert to Unit Test Framework simply rewrite:
0012 /// @code
0013 /// #include <boost/test/minimal.hpp>
0014 ///
0015 /// int test_main( int, char *[] )
0016 /// {
0017 ///   ...
0018 /// }
0019 /// @endcode
0020 /// as
0021 /// @code
0022 /// #include <boost/test/included/unit_test.hpp>
0023 ///
0024 /// BOOST_AUTO_TEST_CASE(test_main)
0025 /// {
0026 ///   ...
0027 /// }
0028 /// @endcode
0029 // ***************************************************************************
0030 
0031 #ifndef BOOST_TEST_MINIMAL_HPP_071894GER
0032 #define BOOST_TEST_MINIMAL_HPP_071894GER
0033 
0034 #include <boost/config/header_deprecated.hpp>
0035 BOOST_HEADER_DEPRECATED( "<boost/test/included/unit_test.hpp>" )
0036 #if defined(BOOST_ALLOW_DEPRECATED_HEADERS)
0037 BOOST_PRAGMA_MESSAGE( "Boost.Test minimal is deprecated. Please convert to the header only variant of Boost.Test." )
0038 #endif
0039 
0040 #define BOOST_CHECK(exp)       \
0041   ( (exp)                      \
0042       ? static_cast<void>(0)   \
0043       : boost::minimal_test::report_error(#exp,__FILE__,__LINE__, BOOST_CURRENT_FUNCTION) )
0044 
0045 #define BOOST_REQUIRE(exp)     \
0046   ( (exp)                      \
0047       ? static_cast<void>(0)   \
0048       : boost::minimal_test::report_critical_error(#exp,__FILE__,__LINE__,BOOST_CURRENT_FUNCTION))
0049 
0050 #define BOOST_ERROR( msg_ )    \
0051         boost::minimal_test::report_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
0052 #define BOOST_FAIL( msg_ )     \
0053         boost::minimal_test::report_critical_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
0054 
0055 //____________________________________________________________________________//
0056 
0057 // Boost.Test
0058 #include <boost/test/detail/global_typedef.hpp>
0059 #include <boost/test/impl/execution_monitor.ipp>
0060 #include <boost/test/impl/debug.ipp>
0061 #include <boost/test/utils/class_properties.hpp>
0062 #include <boost/test/utils/basic_cstring/io.hpp>
0063 
0064 // Boost
0065 #include <boost/cstdlib.hpp>            // for exit codes
0066 #include <boost/current_function.hpp>   // for BOOST_CURRENT_FUNCTION
0067 
0068 // STL
0069 #include <iostream>                     // std::cerr, std::endl
0070 #include <string>                       // std::string
0071 
0072 #include <boost/test/detail/suppress_warnings.hpp>
0073 
0074 //____________________________________________________________________________//
0075 
0076 int test_main( int argc, char* argv[] );  // prototype for users test_main()
0077 
0078 namespace boost {
0079 namespace minimal_test {
0080 
0081 typedef boost::unit_test::const_string const_string;
0082 
0083 inline unit_test::counter_t& errors_counter() { static unit_test::counter_t ec = 0; return ec; }
0084 
0085 inline void
0086 report_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
0087 {
0088     ++errors_counter();
0089     std::cerr << file << "(" << line << "): ";
0090 
0091     if( is_msg )
0092         std::cerr << msg;
0093     else
0094         std::cerr << "test " << msg << " failed";
0095 
0096     if( func_name != "(unknown)" )
0097         std::cerr << " in function: '" << func_name << "'";
0098 
0099     std::cerr << std::endl;
0100 }
0101 
0102 inline void
0103 report_critical_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
0104 {
0105     report_error( msg, file, line, func_name, is_msg );
0106 
0107     throw boost::execution_aborted();
0108 }
0109 
0110 class caller {
0111 public:
0112     // constructor
0113     caller( int argc, char** argv )
0114     : m_argc( argc ), m_argv( argv ) {}
0115 
0116     // execution monitor hook implementation
0117     int operator()() { return test_main( m_argc, m_argv ); }
0118 
0119 private:
0120     // Data members
0121     int         m_argc;
0122     char**      m_argv;
0123 }; // monitor
0124 
0125 } // namespace minimal_test
0126 } // namespace boost
0127 
0128 //____________________________________________________________________________//
0129 
0130 int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
0131 {
0132     using namespace boost::minimal_test;
0133 
0134     try {
0135         ::boost::execution_monitor ex_mon;
0136         int run_result = ex_mon.execute( caller( argc, argv ) );
0137 
0138         BOOST_CHECK( run_result == 0 || run_result == boost::exit_success );
0139     }
0140     catch( boost::execution_exception const& exex ) {
0141         if( exex.code() != boost::execution_exception::no_error )
0142             BOOST_ERROR( (std::string( "exception \"" ) + exex.what() + "\" caught").c_str() );
0143         std::cerr << "\n**** Testing aborted.";
0144     }
0145 
0146     if( boost::minimal_test::errors_counter() != 0 ) {
0147         std::cerr << "\n**** " << errors_counter()
0148                   << " error" << (errors_counter() > 1 ? "s" : "" ) << " detected\n";
0149 
0150         return boost::exit_test_failure;
0151     }
0152 
0153     std::cout << "\n**** no errors detected\n";
0154 
0155     return boost::exit_success;
0156 }
0157 
0158 //____________________________________________________________________________//
0159 
0160 #include <boost/test/detail/enable_warnings.hpp>
0161 
0162 #endif // BOOST_TEST_MINIMAL_HPP_071894GER