1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/test/minimal.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,167 @@
1.4 +// (C) Copyright Gennadiy Rozental 2002-2005.
1.5 +// Distributed under the Boost Software License, Version 1.0.
1.6 +// (See accompanying file LICENSE_1_0.txt or copy at
1.7 +// http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +// See http://www.boost.org/libs/test for the library home page.
1.10 +//
1.11 +// File : $RCSfile: minimal.hpp,v $
1.12 +//
1.13 +// Version : $Revision: 1.19 $
1.14 +//
1.15 +// Description : simple minimal testing definitions and implementation
1.16 +// ***************************************************************************
1.17 +
1.18 +#ifndef BOOST_TEST_MINIMAL_HPP_071894GER
1.19 +#define BOOST_TEST_MINIMAL_HPP_071894GER
1.20 +
1.21 +#define BOOST_CHECK(exp) \
1.22 + ( (exp) \
1.23 + ? static_cast<void>(0) \
1.24 + : boost::minimal_test::report_error(#exp,__FILE__,__LINE__, BOOST_CURRENT_FUNCTION) )
1.25 +
1.26 +#define BOOST_REQUIRE(exp) \
1.27 + ( (exp) \
1.28 + ? static_cast<void>(0) \
1.29 + : boost::minimal_test::report_critical_error(#exp,__FILE__,__LINE__,BOOST_CURRENT_FUNCTION))
1.30 +
1.31 +#define BOOST_ERROR( msg_ ) \
1.32 + boost::minimal_test::report_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
1.33 +#define BOOST_FAIL( msg_ ) \
1.34 + boost::minimal_test::report_critical_error( (msg_),__FILE__,__LINE__, BOOST_CURRENT_FUNCTION, true )
1.35 +
1.36 +//____________________________________________________________________________//
1.37 +
1.38 +// Boost.Test
1.39 +#include <boost/test/detail/global_typedef.hpp>
1.40 +#include <boost/test/impl/execution_monitor.ipp>
1.41 +#include <boost/test/utils/class_properties.hpp>
1.42 +#include <boost/test/utils/basic_cstring/io.hpp>
1.43 +
1.44 +// Boost
1.45 +#include <boost/cstdlib.hpp> // for exit codes#include <boost/cstdlib.hpp> // for exit codes
1.46 +#include <boost/current_function.hpp> // for BOOST_CURRENT_FUNCTION
1.47 +
1.48 +// STL
1.49 +#include <iostream> // std::cerr, std::endl
1.50 +#include <string> // std::string
1.51 +
1.52 +#include <boost/test/detail/suppress_warnings.hpp>
1.53 +
1.54 +//____________________________________________________________________________//
1.55 +
1.56 +int test_main( int argc, char* argv[] ); // prototype for users test_main()
1.57 +
1.58 +namespace boost {
1.59 +namespace minimal_test {
1.60 +
1.61 +typedef boost::unit_test::const_string const_string;
1.62 +
1.63 +inline unit_test::counter_t& errors_counter() { static unit_test::counter_t ec = 0; return ec; }
1.64 +
1.65 +inline void
1.66 +report_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
1.67 +{
1.68 + ++errors_counter();
1.69 + std::cerr << file << "(" << line << "): ";
1.70 +
1.71 + if( is_msg )
1.72 + std::cerr << msg;
1.73 + else
1.74 + std::cerr << "test " << msg << " failed";
1.75 +
1.76 + if( func_name != "(unknown)" )
1.77 + std::cerr << " in function: '" << func_name << "'";
1.78 +
1.79 + std::cerr << std::endl;
1.80 +}
1.81 +
1.82 +inline void
1.83 +report_critical_error( const char* msg, const char* file, int line, const_string func_name, bool is_msg = false )
1.84 +{
1.85 + report_error( msg, file, line, func_name, is_msg );
1.86 +
1.87 + throw boost::execution_aborted();
1.88 +}
1.89 +
1.90 +class caller {
1.91 +public:
1.92 + // constructor
1.93 + caller( int argc, char** argv )
1.94 + : m_argc( argc ), m_argv( argv ) {}
1.95 +
1.96 + // execution monitor hook implementation
1.97 + int operator()() { return test_main( m_argc, m_argv ); }
1.98 +
1.99 +private:
1.100 + // Data members
1.101 + int m_argc;
1.102 + char** m_argv;
1.103 +}; // monitor
1.104 +
1.105 +} // namespace minimal_test
1.106 +
1.107 +} // namespace boost
1.108 +
1.109 +//____________________________________________________________________________//
1.110 +
1.111 +int BOOST_TEST_CALL_DECL main( int argc, char* argv[] )
1.112 +{
1.113 + using namespace boost::minimal_test;
1.114 +
1.115 + try {
1.116 + ::boost::execution_monitor ex_mon;
1.117 + int run_result = ex_mon.execute( caller( argc, argv ) );
1.118 +
1.119 + BOOST_CHECK( run_result == 0 || run_result == boost::exit_success );
1.120 + }
1.121 + catch( boost::execution_exception const& exex ) {
1.122 + if( exex.code() != boost::execution_exception::no_error )
1.123 + BOOST_ERROR( (std::string( "exception \"" ).
1.124 + append( exex.what().begin(), exex.what().end() ).
1.125 + append( "\" caught" ) ).c_str() );
1.126 + std::cerr << "\n**** Testing aborted.";
1.127 + }
1.128 +
1.129 + if( boost::minimal_test::errors_counter() != 0 ) {
1.130 + std::cerr << "\n**** " << errors_counter()
1.131 + << " error" << (errors_counter() > 1 ? "s" : "" ) << " detected\n";
1.132 +
1.133 + return boost::exit_test_failure;
1.134 + }
1.135 +
1.136 + std::cout << "\n**** no errors detected\n";
1.137 +
1.138 + return boost::exit_success;
1.139 +}
1.140 +
1.141 +//____________________________________________________________________________//
1.142 +
1.143 +#include <boost/test/detail/enable_warnings.hpp>
1.144 +
1.145 +// ***************************************************************************
1.146 +// Revision History :
1.147 +//
1.148 +// $Log: minimal.hpp,v $
1.149 +// Revision 1.19 2005/02/20 08:27:06 rogeeff
1.150 +// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
1.151 +//
1.152 +// Revision 1.18 2005/02/01 06:40:06 rogeeff
1.153 +// copyright update
1.154 +// old log entries removed
1.155 +// minor stilistic changes
1.156 +// depricated tools removed
1.157 +//
1.158 +// Revision 1.17 2005/01/31 07:50:05 rogeeff
1.159 +// cdecl portability fix
1.160 +//
1.161 +// Revision 1.16 2005/01/31 06:01:27 rogeeff
1.162 +// BOOST_TEST_CALL_DECL correctness fixes
1.163 +//
1.164 +// Revision 1.15 2005/01/22 19:22:12 rogeeff
1.165 +// implementation moved into headers section to eliminate dependency of included/minimal component on src directory
1.166 +//
1.167 +// ***************************************************************************
1.168 +
1.169 +
1.170 +#endif // BOOST_TEST_MINIMAL_HPP_071894GER