blob: 9c4ee889daf7fb84f341db5e3c1d0cb880243a06 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (C) Copyright Gennadiy Rozental 2005-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: 57992 $
11//
12// Description : implements simple text based progress monitor
13// ***************************************************************************
14
Jeff Thompson3d613fd2013-10-15 15:39:04 -070015#ifndef NDNBOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
16#define NDNBOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070017
18// Boost.Test
19#include <ndnboost/test/progress_monitor.hpp>
20#include <ndnboost/test/unit_test_suite_impl.hpp>
21
22#include <ndnboost/test/detail/unit_test_parameters.hpp>
23
24// Boost
25#include <ndnboost/progress.hpp>
26#include <ndnboost/scoped_ptr.hpp>
27
28#include <ndnboost/test/detail/suppress_warnings.hpp>
29
30//____________________________________________________________________________//
31
32namespace ndnboost {
33
34namespace unit_test {
35
36// ************************************************************************** //
37// ************** progress_monitor ************** //
38// ************************************************************************** //
39
40namespace {
41
42struct progress_monitor_impl {
43 // Constructor
44 progress_monitor_impl()
45 : m_stream( runtime_config::log_sink() )
46 {}
47
48 std::ostream* m_stream;
49 scoped_ptr<progress_display> m_progress_display;
50};
51
52progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; }
53
54} // local namespace
55
56//____________________________________________________________________________//
57
58void
59progress_monitor_t::test_start( counter_t test_cases_amount )
60{
61 s_pm_impl().m_progress_display.reset( new progress_display( test_cases_amount, *s_pm_impl().m_stream ) );
62}
63
64//____________________________________________________________________________//
65
66void
67progress_monitor_t::test_aborted()
68{
69 (*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count();
70}
71
72//____________________________________________________________________________//
73
74void
75progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long )
76{
77 if( tu.p_type == tut_case )
78 ++(*s_pm_impl().m_progress_display);
79}
80
81//____________________________________________________________________________//
82
83void
84progress_monitor_t::test_unit_skipped( test_unit const& tu )
85{
86 test_case_counter tcc;
87 traverse_test_tree( tu, tcc );
88
89 (*s_pm_impl().m_progress_display) += tcc.p_count;
90}
91
92//____________________________________________________________________________//
93
94void
95progress_monitor_t::set_stream( std::ostream& ostr )
96{
97 s_pm_impl().m_stream = &ostr;
98}
99
100//____________________________________________________________________________//
101
102} // namespace unit_test
103
104} // namespace ndnboost
105
106//____________________________________________________________________________//
107
108#include <ndnboost/test/detail/enable_warnings.hpp>
109
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700110#endif // NDNBOOST_TEST_PROGRESS_MONITOR_IPP_020105GER