source: NonGTP/Boost/boost/test/impl/xml_report_formatter.ipp @ 857

Revision 857, 3.9 KB checked in by igarcia, 18 years ago (diff)
Line 
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: xml_report_formatter.ipp,v $
9//
10//  Version     : $Revision: 1.2 $
11//
12//  Description : XML report formatter
13// ***************************************************************************
14
15#ifndef BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
16#define BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
17
18// Boost.Test
19#include <boost/test/results_collector.hpp>
20#include <boost/test/unit_test_suite.hpp>
21#include <boost/test/output/xml_report_formatter.hpp>
22
23#include <boost/test/utils/xml_printer.hpp>
24#include <boost/test/utils/basic_cstring/io.hpp>
25
26#include <boost/test/detail/suppress_warnings.hpp>
27
28//____________________________________________________________________________//
29
30namespace boost {
31
32namespace unit_test {
33
34namespace output {
35
36void
37xml_report_formatter::results_report_start( std::ostream& ostr )
38{
39    ostr << "<TestResult>";
40}
41
42//____________________________________________________________________________//
43
44void
45xml_report_formatter::results_report_finish( std::ostream& ostr )
46{
47    ostr << "</TestResult>";
48}
49
50
51//____________________________________________________________________________//
52
53void
54xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& ostr )
55{
56    test_results const& tr = results_collector.results( tu.p_id );
57
58    const_string descr;
59
60    if( tr.passed() )
61        descr = "passed";
62    else if( tr.p_skipped )
63        descr = "skipped";
64    else if( tr.p_aborted )
65        descr = "aborted";
66    else
67        descr = "failed";
68
69    ostr << '<' << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" )
70         << " name"     << attr_value() << tu.p_name.get()
71         << " result"   << attr_value() << descr
72         << " assertions_passed"        << attr_value() << tr.p_assertions_passed
73         << " assertions_failed"        << attr_value() << tr.p_assertions_failed
74         << " expected_failures"        << attr_value() << tr.p_expected_failures;
75
76    if( tu.p_type == tut_suite )
77        ostr << " test_cases_passed"    << attr_value() << tr.p_test_cases_passed
78             << " test_cases_failed"    << attr_value() << tr.p_test_cases_failed
79             << " test_cases_skipped"   << attr_value() << tr.p_test_cases_skipped;
80             
81   
82    ostr << '>';
83}
84
85//____________________________________________________________________________//
86
87void
88xml_report_formatter::test_unit_report_finish( test_unit const& tu, std::ostream& ostr )
89{
90    ostr << "</" << ( tu.p_type == tut_case ? "TestCase" : "TestSuite" ) << '>';
91}
92
93//____________________________________________________________________________//
94
95void
96xml_report_formatter::do_confirmation_report( test_unit const& tu, std::ostream& ostr )
97{
98    test_unit_report_start( tu, ostr );
99    test_unit_report_finish( tu, ostr );   
100}
101
102//____________________________________________________________________________//
103
104} // namespace output
105
106} // namespace unit_test
107
108} // namespace boost
109
110//____________________________________________________________________________//
111
112#include <boost/test/detail/enable_warnings.hpp>
113
114// ***************************************************************************
115//  Revision History :
116//
117//  $Log: xml_report_formatter.ipp,v $
118//  Revision 1.2  2005/04/29 06:30:07  rogeeff
119//  bug fix for incorect XML output
120//
121//  Revision 1.1  2005/02/20 08:27:07  rogeeff
122//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
123//
124// ***************************************************************************
125
126#endif // BOOST_TEST_XML_REPORT_FORMATTER_IPP_020105GER
Note: See TracBrowser for help on using the repository browser.