Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 1 | // (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 | |
| 15 | #ifndef BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER |
| 16 | #define BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER |
| 17 | |
| 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 | |
| 32 | namespace ndnboost { |
| 33 | |
| 34 | namespace unit_test { |
| 35 | |
| 36 | // ************************************************************************** // |
| 37 | // ************** progress_monitor ************** // |
| 38 | // ************************************************************************** // |
| 39 | |
| 40 | namespace { |
| 41 | |
| 42 | struct 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 | |
| 52 | progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; } |
| 53 | |
| 54 | } // local namespace |
| 55 | |
| 56 | //____________________________________________________________________________// |
| 57 | |
| 58 | void |
| 59 | progress_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 | |
| 66 | void |
| 67 | progress_monitor_t::test_aborted() |
| 68 | { |
| 69 | (*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count(); |
| 70 | } |
| 71 | |
| 72 | //____________________________________________________________________________// |
| 73 | |
| 74 | void |
| 75 | progress_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 | |
| 83 | void |
| 84 | progress_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 | |
| 94 | void |
| 95 | progress_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 | |
| 110 | #endif // BOOST_TEST_PROGRESS_MONITOR_IPP_020105GER |