1 | // (C) Copyright Gennadiy Rozental 2001. |
---|---|
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 |
9 | /// @brief defines specific version of execution monitor used to managed run unit of test cases |
10 | /// |
11 | /// Translates execution exception into error level |
12 | // *************************************************************************** |
13 | |
14 | #ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
15 | #define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
16 | |
17 | // Boost.Test |
18 | #include <boost/test/execution_monitor.hpp> |
19 | #include <boost/test/detail/fwd_decl.hpp> |
20 | #include <boost/test/utils/trivial_singleton.hpp> |
21 | |
22 | #include <boost/test/detail/suppress_warnings.hpp> |
23 | |
24 | //____________________________________________________________________________// |
25 | |
26 | namespace boost { |
27 | namespace unit_test { |
28 | |
29 | // ************************************************************************** // |
30 | // ************** unit_test_monitor ************** // |
31 | // ************************************************************************** // |
32 | |
33 | class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor { |
34 | public: |
35 | enum error_level { |
36 | test_ok = 0, |
37 | precondition_failure = -1, |
38 | unexpected_exception = -2, |
39 | os_exception = -3, |
40 | os_timeout = -4, |
41 | fatal_error = -5 // includes both system and user |
42 | }; |
43 | |
44 | static bool is_critical_error( error_level e ) { return e <= fatal_error; } |
45 | |
46 | // monitor method |
47 | error_level execute_and_translate( boost::function<void ()> const& func, unsigned timeout = 0 ); |
48 | |
49 | private: |
50 | BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t ) |
51 | }; |
52 | |
53 | BOOST_TEST_SINGLETON_INST( unit_test_monitor ) |
54 | |
55 | } // namespace unit_test |
56 | } // namespace boost |
57 | |
58 | #include <boost/test/detail/enable_warnings.hpp> |
59 | |
60 | #endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
61 |