blob: 3fdccfa5910d7ed381423683962a5cc77c14860a [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070016#ifndef NDNBOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
17#define NDNBOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070018
19// Boost.Test
20#include <ndnboost/test/test_observer.hpp>
21
22#include <ndnboost/test/detail/global_typedef.hpp>
23#include <ndnboost/test/detail/fwd_decl.hpp>
24
25#include <ndnboost/test/utils/trivial_singleton.hpp>
26#include <ndnboost/test/utils/class_properties.hpp>
27
28#include <ndnboost/test/detail/suppress_warnings.hpp>
29
30//____________________________________________________________________________//
31
32namespace ndnboost {
33
34namespace unit_test {
35
36// ************************************************************************** //
37// ************** first failed assertion debugger hook ************** //
38// ************************************************************************** //
39
40namespace {
41inline void first_failed_assertion() {}
42}
43
44// ************************************************************************** //
45// ************** test_results ************** //
46// ************************************************************************** //
47
Jeff Thompson3d613fd2013-10-15 15:39:04 -070048class NDNBOOST_TEST_DECL test_results {
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070049public:
50 test_results();
51
Jeff Thompson3d613fd2013-10-15 15:39:04 -070052 typedef NDNBOOST_READONLY_PROPERTY( counter_t, (results_collector_t)(test_results)(results_collect_helper) ) counter_prop;
53 typedef NDNBOOST_READONLY_PROPERTY( bool, (results_collector_t)(test_results)(results_collect_helper) ) bool_prop;
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070054
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070079class NDNBOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> {
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070080public:
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
97private:
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098 NDNBOOST_TEST_SINGLETON_CONS( results_collector_t );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070099};
100
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700101NDNBOOST_TEST_SINGLETON_INST( results_collector )
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700102
103} // namespace unit_test
104
105} // namespace ndnboost
106
107//____________________________________________________________________________//
108
109#include <ndnboost/test/detail/enable_warnings.hpp>
110
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700111#endif // NDNBOOST_TEST_RESULTS_COLLECTOR_HPP_071894GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700112