LCOV - code coverage report
Current view: top level - opt/homebrew/include/boost/test/impl - xml_log_formatter.ipp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 0 90 0.0 %
Date: 2026-06-25 07:23:51 Functions: 0 15 0.0 %

          Line data    Source code
       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)
       5             : 
       6             : //  See http://www.boost.org/libs/test for the library home page.
       7             : //
       8             : //  File        : $RCSfile$
       9             : //
      10             : //  Version     : $Revision$
      11             : //
      12             : //  Description : implements OF_XML Log formatter
      13             : // ***************************************************************************
      14             : 
      15             : #ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
      16             : #define BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
      17             : 
      18             : // Boost.Test
      19             : #include <boost/test/output/xml_log_formatter.hpp>
      20             : #include <boost/test/execution_monitor.hpp>
      21             : #include <boost/test/framework.hpp>
      22             : #include <boost/test/tree/test_unit.hpp>
      23             : #include <boost/test/utils/basic_cstring/io.hpp>
      24             : #include <boost/test/utils/xml_printer.hpp>
      25             : 
      26             : // Boost
      27             : #include <boost/version.hpp>
      28             : 
      29             : // STL
      30             : #include <iostream>
      31             : 
      32             : #include <boost/test/detail/suppress_warnings.hpp>
      33             : 
      34             : //____________________________________________________________________________//
      35             : 
      36             : namespace boost {
      37             : namespace unit_test {
      38             : namespace output {
      39             : 
      40           0 : static const_string tu_type_name( test_unit const& tu )
      41             : {
      42           0 :     return tu.p_type == TUT_CASE ? "TestCase" : "TestSuite";
      43             : }
      44             : 
      45             : // ************************************************************************** //
      46             : // **************               xml_log_formatter              ************** //
      47             : // ************************************************************************** //
      48             : 
      49             : void
      50           0 : xml_log_formatter::log_start( std::ostream& ostr, counter_t )
      51             : {
      52           0 :     ostr  << "<TestLog>";
      53           0 : }
      54             : 
      55             : //____________________________________________________________________________//
      56             : 
      57             : void
      58           0 : xml_log_formatter::log_finish( std::ostream& ostr )
      59             : {
      60           0 :     ostr  << "</TestLog>";
      61           0 : }
      62             : 
      63             : //____________________________________________________________________________//
      64             : 
      65             : void
      66           0 : xml_log_formatter::log_build_info( std::ostream& ostr, bool log_build_info )
      67             : {
      68           0 :     if( log_build_info ) {
      69           0 :         ostr  << "<BuildInfo"
      70           0 :                 << " platform"  << utils::attr_value() << BOOST_PLATFORM
      71           0 :                 << " compiler"  << utils::attr_value() << BOOST_COMPILER
      72           0 :                 << " stl"       << utils::attr_value() << BOOST_STDLIB
      73           0 :                 << " boost=\""  << BOOST_VERSION/100000     << "."
      74           0 :                                 << BOOST_VERSION/100 % 1000 << "."
      75           0 :                                 << BOOST_VERSION % 100      << '\"'
      76           0 :                 << "/>";
      77           0 :     }
      78           0 : }
      79             : 
      80             : //____________________________________________________________________________//
      81             : 
      82             : void
      83           0 : xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu )
      84             : {
      85           0 :     ostr << "<" << tu_type_name( tu ) << " name" << utils::attr_value() << tu.p_name.get();
      86             : 
      87           0 :     if( !tu.p_file_name.empty() )
      88           0 :         ostr << BOOST_TEST_L( " file" ) << utils::attr_value() << tu.p_file_name
      89           0 :              << BOOST_TEST_L( " line" ) << utils::attr_value() << tu.p_line_num;
      90             : 
      91           0 :     ostr << ">";
      92           0 : }
      93             : 
      94             : //____________________________________________________________________________//
      95             : 
      96             : void
      97           0 : xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed )
      98             : {
      99           0 :     if( tu.p_type == TUT_CASE )
     100           0 :         ostr << "<TestingTime>" << elapsed << "</TestingTime>";
     101             : 
     102           0 :     ostr << "</" << tu_type_name( tu ) << ">";
     103           0 : }
     104             : 
     105             : //____________________________________________________________________________//
     106             : 
     107             : void
     108           0 : xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu, const_string reason )
     109             : {
     110           0 :     ostr << "<" << tu_type_name( tu )
     111           0 :          << " name"    << utils::attr_value() << tu.p_name.get()
     112           0 :          << " skipped" << utils::attr_value() << "yes"
     113           0 :          << " reason"  << utils::attr_value() << reason
     114           0 :          << "/>";
     115           0 : }
     116             : 
     117             : //____________________________________________________________________________//
     118             : 
     119             : void
     120           0 : xml_log_formatter::log_exception_start( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex )
     121             : {
     122           0 :     execution_exception::location const& loc = ex.where();
     123             : 
     124           0 :     ostr << "<Exception file" << utils::attr_value() << loc.m_file_name
     125           0 :          << " line"           << utils::attr_value() << loc.m_line_num;
     126             : 
     127           0 :     if( !loc.m_function.is_empty() )
     128           0 :         ostr << " function"   << utils::attr_value() << loc.m_function;
     129             : 
     130           0 :     ostr << ">" << utils::cdata() << ex.what();
     131             : 
     132           0 :     if( !checkpoint_data.m_file_name.is_empty() ) {
     133           0 :         ostr << "<LastCheckpoint file" << utils::attr_value() << checkpoint_data.m_file_name
     134           0 :              << " line"                << utils::attr_value() << checkpoint_data.m_line_num
     135           0 :              << ">"
     136           0 :              << utils::cdata() << checkpoint_data.m_message
     137           0 :              << "</LastCheckpoint>";
     138           0 :     }
     139           0 : }
     140             : 
     141             : //____________________________________________________________________________//
     142             : 
     143             : void
     144           0 : xml_log_formatter::log_exception_finish( std::ostream& ostr )
     145             : {
     146           0 :     ostr << "</Exception>";
     147           0 : }
     148             : 
     149             : //____________________________________________________________________________//
     150             : 
     151             : void
     152           0 : xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& entry_data, log_entry_types let )
     153             : {
     154           0 :     static literal_string xml_tags[] = { "Info", "Message", "Warning", "Error", "FatalError" };
     155             : 
     156           0 :     m_curr_tag = xml_tags[let];
     157           0 :     ostr << '<' << m_curr_tag
     158           0 :          << BOOST_TEST_L( " file" ) << utils::attr_value() << entry_data.m_file_name
     159           0 :          << BOOST_TEST_L( " line" ) << utils::attr_value() << entry_data.m_line_num
     160           0 :          << BOOST_TEST_L( "><![CDATA[" );
     161             : 
     162           0 :     m_value_closed = false;
     163           0 : }
     164             : 
     165             : //____________________________________________________________________________//
     166             : 
     167             : void
     168           0 : xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value )
     169             : {
     170           0 :     utils::print_escaped_cdata( ostr, value );
     171           0 : }
     172             : 
     173             : //____________________________________________________________________________//
     174             : 
     175             : void
     176           0 : xml_log_formatter::log_entry_finish( std::ostream& ostr )
     177             : {
     178           0 :     if( !m_value_closed ) {
     179           0 :         ostr << BOOST_TEST_L( "]]>" );
     180           0 :         m_value_closed = true;
     181           0 :     }
     182             : 
     183           0 :     ostr << BOOST_TEST_L( "</" ) << m_curr_tag << BOOST_TEST_L( ">" );
     184             : 
     185           0 :     m_curr_tag.clear();
     186           0 : }
     187             : 
     188             : //____________________________________________________________________________//
     189             : 
     190             : void
     191           0 : xml_log_formatter::entry_context_start( std::ostream& ostr, log_level )
     192             : {
     193           0 :     if( !m_value_closed ) {
     194           0 :         ostr << BOOST_TEST_L( "]]>" );
     195           0 :         m_value_closed = true;
     196           0 :     }
     197             : 
     198           0 :     ostr << BOOST_TEST_L( "<Context>" );
     199           0 : }
     200             : 
     201             : //____________________________________________________________________________//
     202             : 
     203             : void
     204           0 : xml_log_formatter::entry_context_finish( std::ostream& ostr, log_level )
     205             : {
     206           0 :     ostr << BOOST_TEST_L( "</Context>" );
     207           0 : }
     208             : 
     209             : //____________________________________________________________________________//
     210             : 
     211             : void
     212           0 : xml_log_formatter::log_entry_context( std::ostream& ostr, log_level, const_string context_descr )
     213             : {
     214           0 :     ostr << BOOST_TEST_L( "<Frame>" ) << utils::cdata() << context_descr << BOOST_TEST_L( "</Frame>" );
     215           0 : }
     216             : 
     217             : //____________________________________________________________________________//
     218             : 
     219             : } // namespace output
     220             : } // namespace unit_test
     221             : } // namespace boost
     222             : 
     223             : #include <boost/test/detail/enable_warnings.hpp>
     224             : 
     225             : #endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER

Generated by: LCOV version 1.16