]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/results_collector.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / test / results_collector.hpp
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 testing result collector components
10 ///
11 /// Defines classes for keeping track (@ref test_results) and collecting
12 /// (@ref results_collector_t) the states of the test units.
13 // ***************************************************************************
14
15 #ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
16 #define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
17
18 // Boost.Test
19 #include <boost/test/tree/observer.hpp>
20
21 #include <boost/test/detail/global_typedef.hpp>
22 #include <boost/test/detail/fwd_decl.hpp>
23
24 #include <boost/test/utils/trivial_singleton.hpp>
25 #include <boost/test/utils/class_properties.hpp>
26
27 #include <boost/test/detail/suppress_warnings.hpp>
28
29 //____________________________________________________________________________//
30
31 namespace boost {
32 namespace unit_test {
33
34 namespace {
35
36 // ************************************************************************** //
37 /// First failed assertion debugger hook
38 ///
39 /// This function is a placeholder where user can set a breakpoint in debugger to catch the
40 /// very first assertion failure in each test case
41 // ************************************************************************** //
42 inline void first_failed_assertion() {}
43 }
44
45 // ************************************************************************** //
46 /// @brief Collection of attributes constituting test unit results
47 ///
48 /// This class is a collection of attributes describing a test result.
49 ///
50 /// The attributes presented as public properties on
51 /// an instance of the class. In addition summary conclusion methods are presented to generate simple answer to pass/fail question
52
53 class BOOST_TEST_DECL test_results {
54 public:
55 test_results();
56
57 /// Type representing counter like public property
58 typedef BOOST_READONLY_PROPERTY( counter_t, (results_collector_t)
59 (test_results)
60 (results_collect_helper) ) counter_prop;
61 /// Type representing boolean like public property
62 typedef BOOST_READONLY_PROPERTY( bool, (results_collector_t)
63 (test_results)
64 (results_collect_helper) ) bool_prop;
65
66 counter_prop p_assertions_passed; //!< Number of successful assertions
67 counter_prop p_assertions_failed; //!< Number of failing assertions
68 counter_prop p_warnings_failed; //!< Number of warnings
69 counter_prop p_expected_failures;
70 counter_prop p_test_cases_passed; //!< Number of successfull test cases
71 counter_prop p_test_cases_warned; //!< Number of warnings in test cases
72 counter_prop p_test_cases_failed; //!< Number of failing test cases
73 counter_prop p_test_cases_skipped; //!< Number of skipped test cases
74 counter_prop p_test_cases_aborted; //!< Number of aborted test cases
75 counter_prop p_duration_microseconds; //!< Duration of the test in microseconds
76 bool_prop p_aborted; //!< Indicates that the test unit execution has been aborted
77 bool_prop p_skipped; //!< Indicates that the test unit execution has been skipped
78
79 /// Returns true if test unit passed
80 bool passed() const;
81
82 /// Returns true if the test unit was aborted (hard failure)
83 bool aborted() const;
84
85 /// Produces result code for the test unit execution
86 ///
87 /// This methhod return one of the result codes defined in @c boost/cstdlib.hpp
88 /// @returns
89 /// - @c boost::exit_success on success,
90 /// - @c boost::exit_exception_failure in case test unit
91 /// was aborted for any reason (incuding uncaught exception)
92 /// - and @c boost::exit_test_failure otherwise
93 int result_code() const;
94
95 //! Combines the results of the current instance with another
96 //!
97 //! Only the counters are updated and the @c p_aborted and @c p_skipped are left unchanged.
98 void operator+=( test_results const& );
99
100 //! Resets the current state of the result
101 void clear();
102 };
103
104 // ************************************************************************** //
105 /// @brief Collects and combines the test results
106 ///
107 /// This class collects and combines the results of the test unit during the execution of the
108 /// test tree. The results_collector_t::results() function combines the test results on a subtree
109 /// of the test tree.
110 ///
111 /// @see boost::unit_test::test_observer
112 class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> {
113 public:
114
115 virtual void test_start( counter_t );
116
117 virtual void test_unit_start( test_unit const& );
118 virtual void test_unit_finish( test_unit const&, unsigned long );
119 virtual void test_unit_skipped( test_unit const&, const_string );
120 virtual void test_unit_aborted( test_unit const& );
121
122 virtual void assertion_result( unit_test::assertion_result );
123 virtual void exception_caught( execution_exception const& );
124
125 virtual int priority() { return 3; }
126
127 /// Results access per test unit
128 ///
129 /// @param[in] tu_id id of a test unit
130 test_results const& results( test_unit_id tu_id ) const;
131
132 private:
133 BOOST_TEST_SINGLETON_CONS( results_collector_t )
134 };
135
136 BOOST_TEST_SINGLETON_INST( results_collector )
137
138 } // namespace unit_test
139 } // namespace boost
140
141 #include <boost/test/detail/enable_warnings.hpp>
142
143 #endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER