Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / test / tree / test_case_counter.hpp
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
26 namespace boost {
27 namespace unit_test {
28
29 // ************************************************************************** //
30 // **************                test_case_counter             ************** //
31 // ************************************************************************** //
32
33 ///! Counts the number of enabled test cases
34 class test_case_counter : public test_tree_visitor {
35 public:
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;
44 private:
45     // test tree visitor interface
46     virtual void    visit( test_case const& tc )                { if( m_ignore_status || tc.is_enabled() ) ++p_count.value; }
47     virtual bool    test_suite_start( test_suite const& ts )    { 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