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/// Defines @ref test_case_counter
10// ***************************************************************************
11
12#ifndef BOOST_TEST_TREE_TEST_CASE_COUNTER_HPP_100211GER
13#define BOOST_TEST_TREE_TEST_CASE_COUNTER_HPP_100211GER
14
15// Boost.Test
16#include <boost/test/detail/config.hpp>
17#include <boost/test/utils/class_properties.hpp>
18
19#include <boost/test/tree/test_unit.hpp>
20#include <boost/test/tree/visitor.hpp>
21
22#include <boost/test/detail/suppress_warnings.hpp>
23
24//____________________________________________________________________________//
25
26namespace boost {
27namespace unit_test {
28
29// ************************************************************************** //
30// ************** test_case_counter ************** //
31// ************************************************************************** //
32
33///! Counts the number of enabled test cases
34class test_case_counter : public test_tree_visitor {
35public:
36 // Constructor
37 // @param ignore_disabled ignore the status when counting
38 test_case_counter(bool ignore_status = false)
39 : p_count( 0 )
40 , m_ignore_status(ignore_status)
41 {}
42
43 BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count;
44private:
45 // test tree visitor interface
46 void visit( test_case const& tc ) BOOST_OVERRIDE { if( m_ignore_status || tc.is_enabled() ) ++p_count.value; }
47 bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { return m_ignore_status || ts.is_enabled(); }
48
49 bool m_ignore_status;
50};
51
52} // namespace unit_test
53} // namespace boost
54
55#include <boost/test/detail/enable_warnings.hpp>
56
57#endif // BOOST_TEST_TREE_TEST_CASE_COUNTER_HPP_100211GER
58
59

source code of include/boost/test/tree/test_case_counter.hpp