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) 5 6 // See http://www.boost.org/libs/test for the library home page. 7 // 8 // File : $RCSfile$ 9 // 10 // Version : $Revision: 49312 $ 11 // 12 // Description : defines class unit_test_result that is responsible for 13 // gathering test results and presenting this information to end-user 14 // *************************************************************************** 15 16 #ifndef BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER 17 #define BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER 18 19 // Boost.Test 20 #include <boost/test/test_observer.hpp> 21 22 #include <boost/test/detail/global_typedef.hpp> 23 #include <boost/test/detail/fwd_decl.hpp> 24 25 #include <boost/test/utils/trivial_singleton.hpp> 26 #include <boost/test/utils/class_properties.hpp> 27 28 #include <boost/test/detail/suppress_warnings.hpp> 29 30 //____________________________________________________________________________// 31 32 namespace boost { 33 34 namespace unit_test { 35 36 // ************************************************************************** // 37 // ************** first failed assertion debugger hook ************** // 38 // ************************************************************************** // 39 40 namespace { first_failed_assertion()41inline void first_failed_assertion() {} 42 } 43 44 // ************************************************************************** // 45 // ************** test_results ************** // 46 // ************************************************************************** // 47 48 class BOOST_TEST_DECL test_results { 49 public: 50 test_results(); 51 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; 54 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; 64 65 // "conclusion" methods 66 bool passed() const; 67 int result_code() const; 68 69 // collection helper 70 void operator+=( test_results const& ); 71 72 void clear(); 73 }; 74 75 // ************************************************************************** // 76 // ************** results_collector ************** // 77 // ************************************************************************** // 78 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(); 85 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& ); 90 91 void assertion_result( bool passed ); 92 void exception_caught( execution_exception const& ); 93 94 // results access 95 test_results const& results( test_unit_id ) const; 96 97 private: 98 BOOST_TEST_SINGLETON_CONS( results_collector_t ); 99 }; 100 101 BOOST_TEST_SINGLETON_INST( results_collector ) 102 103 } // namespace unit_test 104 105 } // namespace boost 106 107 //____________________________________________________________________________// 108 109 #include <boost/test/detail/enable_warnings.hpp> 110 111 #endif // BOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER 112 113