[857] | 1 | // (C) Copyright Gennadiy Rozental 2005.
|
---|
| 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: progress_monitor.ipp,v $
|
---|
| 9 | //
|
---|
| 10 | // Version : $Revision: 1.1 $
|
---|
| 11 | //
|
---|
| 12 | // Description : implements simple text based progress monitor
|
---|
| 13 | // ***************************************************************************
|
---|
| 14 |
|
---|
| 15 | #ifndef BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
|
---|
| 16 | #define BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
|
---|
| 17 |
|
---|
| 18 | // Boost.Test
|
---|
| 19 | #include <boost/test/progress_monitor.hpp>
|
---|
| 20 | #include <boost/test/unit_test_suite.hpp>
|
---|
| 21 |
|
---|
| 22 | // Boost
|
---|
| 23 | #include <boost/progress.hpp>
|
---|
| 24 | #include <boost/scoped_ptr.hpp>
|
---|
| 25 |
|
---|
| 26 | #include <boost/test/detail/suppress_warnings.hpp>
|
---|
| 27 |
|
---|
| 28 | //____________________________________________________________________________//
|
---|
| 29 |
|
---|
| 30 | namespace boost {
|
---|
| 31 |
|
---|
| 32 | namespace unit_test {
|
---|
| 33 |
|
---|
| 34 | // ************************************************************************** //
|
---|
| 35 | // ************** progress_monitor ************** //
|
---|
| 36 | // ************************************************************************** //
|
---|
| 37 |
|
---|
| 38 | namespace {
|
---|
| 39 |
|
---|
| 40 | struct progress_monitor_impl {
|
---|
| 41 | // Constructor
|
---|
| 42 | progress_monitor_impl()
|
---|
| 43 | : m_stream( &std::cout )
|
---|
| 44 | {}
|
---|
| 45 |
|
---|
| 46 | std::ostream* m_stream;
|
---|
| 47 | scoped_ptr<progress_display> m_progress_display;
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; }
|
---|
| 51 |
|
---|
| 52 | } // local namespace
|
---|
| 53 |
|
---|
| 54 | //____________________________________________________________________________//
|
---|
| 55 |
|
---|
| 56 | void
|
---|
| 57 | progress_monitor_t::test_start( counter_t test_cases_amount )
|
---|
| 58 | {
|
---|
| 59 | s_pm_impl().m_progress_display.reset( new progress_display( test_cases_amount, *s_pm_impl().m_stream ) );
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | //____________________________________________________________________________//
|
---|
| 63 |
|
---|
| 64 | void
|
---|
| 65 | progress_monitor_t::test_aborted()
|
---|
| 66 | {
|
---|
| 67 | (*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | //____________________________________________________________________________//
|
---|
| 71 |
|
---|
| 72 | void
|
---|
| 73 | progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long )
|
---|
| 74 | {
|
---|
| 75 | if( tu.p_type == tut_case )
|
---|
| 76 | ++(*s_pm_impl().m_progress_display);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | //____________________________________________________________________________//
|
---|
| 80 |
|
---|
| 81 | void
|
---|
| 82 | progress_monitor_t::test_unit_skipped( test_unit const& tu )
|
---|
| 83 | {
|
---|
| 84 | test_case_counter tcc;
|
---|
| 85 | traverse_test_tree( tu, tcc );
|
---|
| 86 |
|
---|
| 87 | (*s_pm_impl().m_progress_display) += tcc.m_count;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | //____________________________________________________________________________//
|
---|
| 91 |
|
---|
| 92 | void
|
---|
| 93 | progress_monitor_t::set_stream( std::ostream& ostr )
|
---|
| 94 | {
|
---|
| 95 | s_pm_impl().m_stream = &ostr;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //____________________________________________________________________________//
|
---|
| 99 |
|
---|
| 100 | } // namespace unit_test
|
---|
| 101 |
|
---|
| 102 | } // namespace boost
|
---|
| 103 |
|
---|
| 104 | //____________________________________________________________________________//
|
---|
| 105 |
|
---|
| 106 | #include <boost/test/detail/enable_warnings.hpp>
|
---|
| 107 |
|
---|
| 108 | // ***************************************************************************
|
---|
| 109 | // Revision History :
|
---|
| 110 | //
|
---|
| 111 | // $Log: progress_monitor.ipp,v $
|
---|
| 112 | // Revision 1.1 2005/02/20 08:27:07 rogeeff
|
---|
| 113 | // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
|
---|
| 114 | //
|
---|
| 115 | // ***************************************************************************
|
---|
| 116 |
|
---|
| 117 | #endif // BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER
|
---|