]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/impl/test_framework_init_observer.ipp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / test / impl / test_framework_init_observer.ipp
1 // (c) Copyright Raffi Enficiaud 2017.
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 //! An observer for monitoring the success/failure of the other observers
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_FRAMEWORK_INIT_OBSERVER_IPP_021105GER
13 #define BOOST_TEST_FRAMEWORK_INIT_OBSERVER_IPP_021105GER
14
15 // Boost.Test
16 #include <boost/test/test_framework_init_observer.hpp>
17 #include <boost/test/framework.hpp>
18 #include <boost/test/detail/suppress_warnings.hpp>
19
20 //____________________________________________________________________________//
21
22 namespace boost {
23 namespace unit_test {
24
25
26 //____________________________________________________________________________//
27
28 // ************************************************************************** //
29 // ************** framework_init_observer_t ************** //
30 // ************************************************************************** //
31
32 namespace {
33
34 struct test_init_observer_check {
35 bool has_failure;
36
37 void clear()
38 {
39 has_failure = false;
40 }
41 };
42
43
44 test_init_observer_check& s_tioc_impl() { static test_init_observer_check the_inst; return the_inst; }
45
46 } // local namespace
47
48
49 //____________________________________________________________________________//
50
51 // singleton pattern
52 BOOST_TEST_SINGLETON_CONS_IMPL(framework_init_observer_t)
53
54 //____________________________________________________________________________//
55
56 void
57 framework_init_observer_t::clear()
58 {
59 if(!framework::test_in_progress())
60 s_tioc_impl().clear();
61 }
62
63 //____________________________________________________________________________//
64
65 void
66 framework_init_observer_t::test_start( counter_t )
67 {
68 clear();
69 }
70
71 //____________________________________________________________________________//
72
73 void
74 framework_init_observer_t::assertion_result( unit_test::assertion_result ar )
75 {
76 test_init_observer_check& tr = s_tioc_impl();
77 switch( ar ) {
78 case AR_TRIGGERED: break;
79 case AR_PASSED: break;
80 case AR_FAILED: tr.has_failure = true; break;
81 default:
82 break;
83 }
84 }
85
86 //____________________________________________________________________________//
87
88 void
89 framework_init_observer_t::exception_caught( execution_exception const& )
90 {
91 test_init_observer_check& tr = s_tioc_impl();
92 tr.has_failure = true;
93 }
94
95 void
96 framework_init_observer_t::test_aborted()
97 {
98 s_tioc_impl().has_failure = true;
99 }
100
101
102 //____________________________________________________________________________//
103
104 bool
105 framework_init_observer_t::has_failed() const
106 {
107 return s_tioc_impl().has_failure;
108 }
109
110 //____________________________________________________________________________//
111
112 } // namespace unit_test
113 } // namespace boost
114
115 #include <boost/test/detail/enable_warnings.hpp>
116
117 #endif // BOOST_TEST_FRAMEWORK_INIT_OBSERVER_IPP_021105GER