Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/test/impl/unit_test_main.ipp @ 44

Last change on this file since 44 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.9 KB
Line 
1//  (C) Copyright Gennadiy Rozental 2001-2005.
2//  Distributed under the Boost Software License, Version 1.0.
3//  (See accompanying file LICENSE_1_0.txt or copy at
4//  http://www.boost.org/LICENSE_1_0.txt)
5
6//  See http://www.boost.org/libs/test for the library home page.
7//
8//  File        : $RCSfile: unit_test_main.ipp,v $
9//
10//  Version     : $Revision: 1.9 $
11//
12//  Description : main function implementation for Unit Test Framework
13// ***************************************************************************
14
15#ifndef BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
16#define BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
17
18// Boost.Test
19#include <boost/test/framework.hpp>
20#include <boost/test/results_collector.hpp>
21#include <boost/test/unit_test_suite_impl.hpp>
22#include <boost/test/results_reporter.hpp>
23
24#include <boost/test/detail/unit_test_parameters.hpp>
25
26// Boost
27#include <boost/cstdlib.hpp>
28
29// STL
30#include <stdexcept>
31#include <iostream>
32
33#include <boost/test/detail/suppress_warnings.hpp>
34
35//____________________________________________________________________________//
36
37// ************************************************************************** //
38// **************                  unit_test_main              ************** //
39// ************************************************************************** //
40
41namespace boost {
42
43namespace unit_test {
44
45int BOOST_TEST_DECL
46
47#if defined(BOOST_TEST_DYN_LINK)
48unit_test_main( bool (*init_unit_test_func)(), int argc, char* argv[] )
49#else
50unit_test_main(                                int argc, char* argv[] )
51#endif
52{
53    try {
54        framework::init( argc, argv );
55
56#ifdef BOOST_TEST_DYN_LINK
57    if( !(*init_unit_test_func)() )
58        throw framework::setup_error( BOOST_TEST_L( "test tree initialization error" ) );
59#endif
60
61        framework::run();
62
63        results_reporter::make_report();
64
65        return runtime_config::no_result_code()
66                    ? boost::exit_success
67                    : results_collector.results( framework::master_test_suite().p_id ).result_code();
68    }
69    catch( framework::internal_error const& ex ) {
70        std::cerr << "Boost.Test framework internal error: " << ex.what() << std::endl;
71       
72        return boost::exit_exception_failure;
73    }
74    catch( framework::setup_error const& ex ) {
75        std::cerr << "Test setup error: " << ex.what() << std::endl;
76       
77        return boost::exit_exception_failure;
78    }
79    catch( ... ) {
80        std::cerr << "Boost.Test framework internal error: unknown reason" << std::endl;
81       
82        return boost::exit_exception_failure;
83    }
84}
85
86} // namespace unit_test
87
88} // namespace boost
89
90#if !defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
91
92// ************************************************************************** //
93// **************        main function for tests using lib     ************** //
94// ************************************************************************** //
95
96int BOOST_TEST_CALL_DECL
97main( int argc, char* argv[] )
98{
99    return ::boost::unit_test::unit_test_main( argc, argv );
100}
101
102#endif // !BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
103
104//____________________________________________________________________________//
105
106#include <boost/test/detail/enable_warnings.hpp>
107
108// ***************************************************************************
109//  Revision History :
110//
111//  $Log: unit_test_main.ipp,v $
112//  Revision 1.9  2006/03/19 11:45:26  rogeeff
113//  main function renamed for consistancy
114//
115//  Revision 1.8  2006/03/19 07:27:52  rogeeff
116//  streamline test setup error message
117//
118//  Revision 1.7  2005/12/14 05:35:57  rogeeff
119//  DLL support implemented
120//  Alternative init API introduced
121//
122//  Revision 1.6  2005/02/20 08:27:07  rogeeff
123//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
124//
125// ***************************************************************************
126
127#endif // BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
Note: See TracBrowser for help on using the repository browser.