test_main.ipp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // (C) Copyright Beman Dawes 1995-2001.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // See http://www.boost.org/libs/test for the library home page.
  7. //
  8. /// @file
  9. /// @brief Implements main function for Test Execution Monitor.
  10. // ***************************************************************************
  11. #ifndef BOOST_TEST_TEST_MAIN_IPP_012205GER
  12. #define BOOST_TEST_TEST_MAIN_IPP_012205GER
  13. // Boost.Test
  14. #include <boost/test/framework.hpp>
  15. #include <boost/test/test_tools.hpp>
  16. #include <boost/test/unit_test_suite.hpp>
  17. // Boost
  18. #include <boost/cstdlib.hpp>
  19. #include <boost/test/detail/suppress_warnings.hpp>
  20. //____________________________________________________________________________//
  21. extern int test_main( int argc, char* argv[] ); // prototype for user's test_main()
  22. struct test_main_caller {
  23. test_main_caller( int argc, char** argv ) : m_argc( argc ), m_argv( argv ) {}
  24. void operator()() {
  25. int test_main_result = test_main( m_argc, m_argv );
  26. // translate a test_main non-success return into a test error
  27. BOOST_CHECK( test_main_result == 0 || test_main_result == boost::exit_success );
  28. }
  29. private:
  30. // Data members
  31. int m_argc;
  32. char** m_argv;
  33. };
  34. // ************************************************************************** //
  35. // ************** test main ************** //
  36. // ************************************************************************** //
  37. ::boost::unit_test::test_suite*
  38. init_unit_test_suite( int argc, char* argv[] ) {
  39. using namespace ::boost::unit_test;
  40. framework::master_test_suite().p_name.value = "Test Program";
  41. framework::master_test_suite().add( BOOST_TEST_CASE( test_main_caller( argc, argv ) ) );
  42. return 0;
  43. }
  44. //____________________________________________________________________________//
  45. #include <boost/test/detail/enable_warnings.hpp>
  46. #endif // BOOST_TEST_TEST_MAIN_IPP_012205GER