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)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
12 // Description : plain report formatter definition
13 // ***************************************************************************
15 #ifndef BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER
16 #define BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER
19 #include <boost/test/output/plain_report_formatter.hpp>
20 #include <boost/test/utils/custom_manip.hpp>
21 #include <boost/test/results_collector.hpp>
22 #include <boost/test/unit_test_parameters.hpp>
24 #include <boost/test/tree/test_unit.hpp>
26 #include <boost/test/utils/basic_cstring/io.hpp>
27 #include <boost/test/utils/setcolor.hpp>
31 #include <boost/config/no_tr1/cmath.hpp>
34 #include <boost/test/detail/suppress_warnings.hpp>
36 # ifdef BOOST_NO_STDC_NAMESPACE
37 namespace std { using ::log10; }
40 //____________________________________________________________________________//
48 typedef utils::custom_manip<struct quote_t> quote;
52 operator<<( utils::custom_printer<quote> const& p, T const& value )
54 *p << '"' << value << '"';
59 //____________________________________________________________________________//
62 print_stat_value( std::ostream& ostr, counter_t v, counter_t indent, counter_t total, const_string name, const_string res )
68 ostr << std::setw( static_cast<int>(indent) ) << "" << v << ' ' << name << ( v != 1 ? "s" : "" )
69 << " out of " << total << ' ' << res << '\n';
71 ostr << std::setw( static_cast<int>(indent) ) << "" << v << ' ' << res << ' ' << name << ( v != 1 ? "s" : "" ) << '\n';
74 //____________________________________________________________________________//
78 // ************************************************************************** //
79 // ************** plain_report_formatter ************** //
80 // ************************************************************************** //
83 plain_report_formatter::results_report_start( std::ostream& ostr )
86 m_color_output = runtime_config::get<bool>( runtime_config::btrt_color_output );
90 //____________________________________________________________________________//
93 plain_report_formatter::results_report_finish( std::ostream& ostr )
98 //____________________________________________________________________________//
101 plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr )
103 test_results const& tr = results_collector.results( tu.p_id );
108 descr = "has passed";
109 else if( tr.p_skipped )
110 descr = "was skipped";
111 else if( tr.p_aborted )
112 descr = "was aborted";
114 descr = "has failed";
116 ostr << std::setw( static_cast<int>(m_indent) ) << ""
117 << "Test " << tu.p_type_name << ' ' << quote() << tu.full_name() << ' ' << descr;
125 counter_t total_assertions = tr.p_assertions_passed + tr.p_assertions_failed;
126 counter_t total_tc = tr.p_test_cases_passed + tr.p_test_cases_warned + tr.p_test_cases_failed + tr.p_test_cases_skipped;
128 if( total_assertions > 0 || total_tc > 0 || tr.p_warnings_failed > 0)
134 print_stat_value( ostr, tr.p_test_cases_passed , m_indent, total_tc , "test case", "passed" );
135 print_stat_value( ostr, tr.p_test_cases_warned , m_indent, total_tc , "test case", "passed with warnings" );
136 print_stat_value( ostr, tr.p_test_cases_failed , m_indent, total_tc , "test case", "failed" );
137 print_stat_value( ostr, tr.p_test_cases_skipped, m_indent, total_tc , "test case", "skipped" );
138 print_stat_value( ostr, tr.p_test_cases_aborted, m_indent, total_tc , "test case", "aborted" );
139 print_stat_value( ostr, tr.p_assertions_passed , m_indent, total_assertions, "assertion", "passed" );
140 print_stat_value( ostr, tr.p_assertions_failed , m_indent, total_assertions, "assertion", "failed" );
141 print_stat_value( ostr, tr.p_warnings_failed , m_indent, 0 , "warning" , "failed" );
142 print_stat_value( ostr, tr.p_expected_failures , m_indent, 0 , "failure" , "expected" );
147 //____________________________________________________________________________//
150 plain_report_formatter::test_unit_report_finish( test_unit const&, std::ostream& )
155 //____________________________________________________________________________//
158 plain_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr )
160 test_results const& tr = results_collector.results( tu.p_id );
163 BOOST_TEST_SCOPE_SETCOLOR( m_color_output, ostr, term_attr::BRIGHT, term_color::GREEN );
165 ostr << "*** No errors detected\n";
169 BOOST_TEST_SCOPE_SETCOLOR( m_color_output, ostr, term_attr::BRIGHT, term_color::RED );
172 ostr << "*** The test " << tu.p_type_name << ' ' << quote() << tu.full_name() << " was skipped"
173 << "; see standard output for details\n";
178 ostr << "*** The test " << tu.p_type_name << ' ' << quote() << tu.full_name() << " was aborted"
179 << "; see standard output for details\n";
182 if( tr.p_assertions_failed == 0 ) {
184 ostr << "*** Errors were detected in the test " << tu.p_type_name << ' ' << quote() << tu.full_name()
185 << "; see standard output for details\n";
189 counter_t num_failures = tr.p_assertions_failed;
191 ostr << "*** " << num_failures << " failure" << ( num_failures != 1 ? "s are" : " is" ) << " detected";
193 if( tr.p_expected_failures > 0 )
194 ostr << " (" << tr.p_expected_failures << " failure" << ( tr.p_expected_failures != 1 ? "s are" : " is" ) << " expected)";
196 ostr << " in the test " << tu.p_type_name << " " << quote() << tu.full_name() << "\n";
199 //____________________________________________________________________________//
201 } // namespace output
202 } // namespace unit_test
205 #include <boost/test/detail/enable_warnings.hpp>
207 #endif // BOOST_TEST_PLAIN_REPORT_FORMATTER_IPP_020105GER