source: NonGTP/Boost/boost/test/impl/unit_test_monitor.ipp @ 857

Revision 857, 4.4 KB checked in by igarcia, 18 years ago (diff)
Line 
1//  (C) Copyright Gennadiy Rozental 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_monitor.ipp,v $
9//
10//  Version     : $Revision: 1.3 $
11//
12//  Description : implements specific subclass of Executon Monitor used by Unit
13//  Test Framework to monitor test cases run.
14// ***************************************************************************
15
16#ifndef BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
17#define BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
18
19// Boost.Test
20#include <boost/test/unit_test_monitor.hpp>
21#include <boost/test/unit_test_suite.hpp>
22#include <boost/test/test_tools.hpp>
23#include <boost/test/framework.hpp>
24
25#include <boost/test/detail/unit_test_parameters.hpp>
26
27#include <boost/test/detail/suppress_warnings.hpp>
28
29//____________________________________________________________________________//
30
31namespace boost {
32
33namespace unit_test {
34
35namespace {
36struct zero_return_wrapper {
37    explicit zero_return_wrapper( callback0<> const& f ) : m_f( f ) {}
38   
39    int operator()() { m_f(); return 0; }
40   
41    callback0<> const& m_f;
42};
43
44}
45
46// ************************************************************************** //
47// **************               unit_test_monitor              ************** //
48// ************************************************************************** //
49
50unit_test_monitor_t::error_level
51unit_test_monitor_t::execute_and_translate( test_case const& tc )
52{
53    try {
54        execute( callback0<int>( zero_return_wrapper( tc.test_func() ) ),
55                 runtime_config::catch_sys_errors(),
56                 tc.p_timeout );
57    }
58    catch( execution_exception const& ex ) {
59        framework::exception_caught( ex );
60        framework::test_unit_aborted();
61
62        // translate execution_exception::error_code to error_level
63        switch( ex.code() ) {
64        case execution_exception::no_error:             return test_ok;
65        case execution_exception::user_error:           return unexpected_exception;
66        case execution_exception::cpp_exception_error:  return unexpected_exception;
67        case execution_exception::system_error:         return os_exception;
68        case execution_exception::timeout_error:        return os_timeout;
69        case execution_exception::user_fatal_error:
70        case execution_exception::system_fatal_error:   return fatal_error;
71        default:                                        return unexpected_exception;
72        }
73    }
74
75    return test_ok;
76}
77
78//____________________________________________________________________________//
79
80} // namespace unit_test
81
82} // namespace boost
83
84//____________________________________________________________________________//
85
86#include <boost/test/detail/enable_warnings.hpp>
87
88// ***************************************************************************
89//  Revision History :
90//
91//  $Log: unit_test_monitor.ipp,v $
92//  Revision 1.3  2005/02/20 08:27:07  rogeeff
93//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
94//
95//  Revision 1.2  2005/02/01 06:40:07  rogeeff
96//  copyright update
97//  old log entries removed
98//  minor stilistic changes
99//  depricated tools removed
100//
101//  Revision 1.1  2005/01/22 19:22:13  rogeeff
102//  implementation moved into headers section to eliminate dependency of included/minimal component on src directory
103//
104//  Revision 1.17  2005/01/19 16:34:07  vawjr
105//  Changed the \r\r\n back to \r\n on windows so we don't get errors when compiling
106//  on VC++8.0.  I don't know why Microsoft thinks it's a good idea to call this an error,
107//  but they do.  I also don't know why people insist on checking out files on Windows and
108//  copying them to a unix system to check them in (which will cause exactly this problem)
109//
110//  Revision 1.16  2005/01/18 08:30:08  rogeeff
111//  unit_test_log rework:
112//     eliminated need for ::instance()
113//     eliminated need for << end and ...END macro
114//     straitend interface between log and formatters
115//     change compiler like formatter name
116//     minimized unit_test_log interface and reworked to use explicit calls
117//
118// ***************************************************************************
119
120#endif // BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
Note: See TracBrowser for help on using the repository browser.