fix doc example typo
[boost.git] / boost / test / results_collector.hpp
blobe4200b025d7945af1616aaefb6fcfbd18c05ef8e
1 // (C) Copyright Gennadiy Rozental 2001-2008.
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)
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 // File : $RCSfile$
9 //
10 // Version : $Revision$
12 // Description : defines class unit_test_result that is responsible for
13 // gathering test results and presenting this information to end-user
14 // ***************************************************************************
16 #ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
17 #define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
19 // Boost.Test
20 #include <boost/test/test_observer.hpp>
22 #include <boost/test/detail/global_typedef.hpp>
23 #include <boost/test/detail/fwd_decl.hpp>
25 #include <boost/test/utils/trivial_singleton.hpp>
26 #include <boost/test/utils/class_properties.hpp>
28 #include <boost/test/detail/suppress_warnings.hpp>
30 //____________________________________________________________________________//
32 namespace boost {
34 namespace unit_test {
36 // ************************************************************************** //
37 // ************** first failed assertion debugger hook ************** //
38 // ************************************************************************** //
40 namespace {
41 inline void first_failed_assertion() {}
44 // ************************************************************************** //
45 // ************** test_results ************** //
46 // ************************************************************************** //
48 class BOOST_TEST_DECL test_results {
49 public:
50 test_results();
52 typedef BOOST_READONLY_PROPERTY( counter_t, (results_collector_t)(test_results)(results_collect_helper) ) counter_prop;
53 typedef BOOST_READONLY_PROPERTY( bool, (results_collector_t)(test_results)(results_collect_helper) ) bool_prop;
55 counter_prop p_assertions_passed;
56 counter_prop p_assertions_failed;
57 counter_prop p_expected_failures;
58 counter_prop p_test_cases_passed;
59 counter_prop p_test_cases_failed;
60 counter_prop p_test_cases_skipped;
61 counter_prop p_test_cases_aborted;
62 bool_prop p_aborted;
63 bool_prop p_skipped;
65 // "conclusion" methods
66 bool passed() const;
67 int result_code() const;
69 // collection helper
70 void operator+=( test_results const& );
72 void clear();
75 // ************************************************************************** //
76 // ************** results_collector ************** //
77 // ************************************************************************** //
79 class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> {
80 public:
81 // test_observer interface implementation
82 void test_start( counter_t test_cases_amount );
83 void test_finish();
84 void test_aborted();
86 void test_unit_start( test_unit const& );
87 void test_unit_finish( test_unit const&, unsigned long elapsed );
88 void test_unit_skipped( test_unit const& );
89 void test_unit_aborted( test_unit const& );
91 void assertion_result( bool passed );
92 void exception_caught( execution_exception const& );
94 // results access
95 test_results const& results( test_unit_id ) const;
97 private:
98 BOOST_TEST_SINGLETON_CONS( results_collector_t );
101 BOOST_TEST_SINGLETON_INST( results_collector )
103 } // namespace unit_test
105 } // namespace boost
107 //____________________________________________________________________________//
109 #include <boost/test/detail/enable_warnings.hpp>
111 #endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER