]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/include/boost/test/results_collector.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / results_collector.hpp
CommitLineData
7c673cae
FG
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
31namespace boost {
32namespace unit_test {
33
34namespace {
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// ************************************************************************** //
42inline 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
53class BOOST_TEST_DECL test_results {
54public:
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 /// Produces result code for the test unit execution
83 ///
84 /// This methhod return one of the result codes defined in @c boost/cstdlib.hpp
85 /// @returns
86 /// - @c boost::exit_success on success,
87 /// - @c boost::exit_exception_failure in case test unit
88 /// was aborted for any reason (incuding uncaught exception)
89 /// - and @c boost::exit_test_failure otherwise
90 int result_code() const;
91
92 //! Combines the results of the current instance with another
93 //!
94 //! Only the counters are updated and the @c p_aborted and @c p_skipped are left unchanged.
95 void operator+=( test_results const& );
96
97 //! Resets the current state of the result
98 void clear();
99};
100
101// ************************************************************************** //
102/// @brief Collects and combines the test results
103///
104/// This class collects and combines the results of the test unit during the execution of the
105/// test tree. The results_collector_t::results() function combines the test results on a subtree
106/// of the test tree.
107///
108/// @see boost::unit_test::test_observer
109class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> {
110public:
111
112 virtual void test_start( counter_t );
113
114 virtual void test_unit_start( test_unit const& );
115 virtual void test_unit_finish( test_unit const&, unsigned long );
116 virtual void test_unit_skipped( test_unit const&, const_string );
117 virtual void test_unit_aborted( test_unit const& );
118
119 virtual void assertion_result( unit_test::assertion_result );
120 virtual void exception_caught( execution_exception const& );
121
122 virtual int priority() { return 2; }
123
124 /// Results access per test unit
125 ///
126 /// @param[in] tu_id id of a test unit
127 test_results const& results( test_unit_id tu_id ) const;
128
129private:
130 BOOST_TEST_SINGLETON_CONS( results_collector_t )
131};
132
133BOOST_TEST_SINGLETON_INST( results_collector )
134
135} // namespace unit_test
136} // namespace boost
137
138#include <boost/test/detail/enable_warnings.hpp>
139
140#endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER