test_main.ipp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // (C) Copyright Gennadiy Rozental 2001-2008.
  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 : $RCSfile$
  9. //
  10. // Version : $$Revision: 49312 $
  11. //
  12. // Description : implements main function for Test Execution Monitor.
  13. // ***************************************************************************
  14. #ifndef BOOST_TEST_TEST_MAIN_IPP_012205GER
  15. #define BOOST_TEST_TEST_MAIN_IPP_012205GER
  16. // Boost.Test
  17. #include <boost/test/framework.hpp>
  18. #include <boost/test/test_tools.hpp>
  19. #include <boost/test/unit_test_suite.hpp>
  20. // Boost
  21. #include <boost/cstdlib.hpp>
  22. #include <boost/test/detail/suppress_warnings.hpp>
  23. //____________________________________________________________________________//
  24. extern int test_main( int argc, char* argv[] ); // prototype for user's test_main()
  25. struct test_main_caller {
  26. test_main_caller( int argc, char** argv ) : m_argc( argc ), m_argv( argv ) {}
  27. void operator()() {
  28. int test_main_result = test_main( m_argc, m_argv );
  29. // translate a test_main non-success return into a test error
  30. BOOST_CHECK( test_main_result == 0 || test_main_result == boost::exit_success );
  31. }
  32. private:
  33. // Data members
  34. int m_argc;
  35. char** m_argv;
  36. };
  37. // ************************************************************************** //
  38. // ************** test main ************** //
  39. // ************************************************************************** //
  40. ::boost::unit_test::test_suite*
  41. init_unit_test_suite( int argc, char* argv[] ) {
  42. using namespace ::boost::unit_test;
  43. framework::master_test_suite().p_name.value = "Test Program";
  44. framework::master_test_suite().add( BOOST_TEST_CASE( test_main_caller( argc, argv ) ) );
  45. return 0;
  46. }
  47. //____________________________________________________________________________//
  48. #include <boost/test/detail/enable_warnings.hpp>
  49. #endif // BOOST_TEST_TEST_MAIN_IPP_012205GER