Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:09:21

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// @brief defines testing result reporter interfaces
0010 ///
0011 /// This file defines interfaces that are responsible for results reporting. Interface is presented in a form of
0012 /// free standing function implemented in namespace result_reporter
0013 // ***************************************************************************
0014 
0015 #ifndef BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
0016 #define BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
0017 
0018 // Boost.Test
0019 #include <boost/test/detail/global_typedef.hpp>
0020 #include <boost/test/detail/fwd_decl.hpp>
0021 
0022 // STL
0023 #include <iosfwd>   // for std::ostream&
0024 
0025 #include <boost/test/detail/suppress_warnings.hpp>
0026 
0027 //____________________________________________________________________________//
0028 
0029 namespace boost {
0030 namespace unit_test {
0031 
0032 /// Namespace for results reporter interfaces
0033 namespace results_reporter {
0034 
0035 // ************************************************************************** //
0036 /// @brief Results report formatter interface
0037 ///
0038 /// This is abstract interface for the report formatter used by results reporter routines.
0039 /// You can define a custom formatter by implementing this interface and setting the formatter using set_format function.
0040 /// This is usually done during test module initialization
0041 // ************************************************************************** //
0042 
0043 class BOOST_TEST_DECL format {
0044 public:
0045     // Destructor
0046     virtual ~format() {}
0047 
0048     virtual void    results_report_start( std::ostream& ostr ) = 0;
0049     virtual void    results_report_finish( std::ostream& ostr ) = 0;
0050 
0051     virtual void    test_unit_report_start( test_unit const&, std::ostream& ostr ) = 0;
0052     virtual void    test_unit_report_finish( test_unit const&, std::ostream& ostr ) = 0;
0053 
0054     virtual void    do_confirmation_report( test_unit const&, std::ostream& ostr ) = 0;
0055 };
0056 
0057 // ************************************************************************** //
0058 /// @name report configuration
0059 // ************************************************************************** //
0060 
0061 /// Sets reporting level
0062 
0063 /// There are only four possible levels for results report:
0064 /// - confirmation report (boost::unit_test::CONFIRMATION_REPORT). This report level only produces short confirmation
0065 ///   message about test module pass/fail status
0066 /// - short report (boost::unit_test::SHORT_REPORT). This report level produces short summary report for failed/passed
0067 ///   assertions and test units.
0068 /// - detailed report (boost::unit_test::DETAILED_REPORT). This report level produces detailed report per test unit for
0069 ///   passed/failed assertions and uncaught exceptions
0070 /// - no report (boost::unit_test::NO_REPORT). This report level produces no results report. This is used for test modules
0071 ///   running as part of some kind of continues integration framework
0072 /// @param[in] l report level
0073 BOOST_TEST_DECL void    set_level( report_level l );
0074 
0075 /// Sets output stream for results reporting
0076 
0077 /// By default std::cerr is used. Use this function to set a different stream. The framework
0078 /// refers to the stream by reference, so you need to make sure the stream object lifetime exceeds the testing main scope.
0079 BOOST_TEST_DECL void    set_stream( std::ostream& );
0080 
0081 /// Sets one of the predefined formats
0082 
0083 /// The framework implements two results report formats:
0084 /// - plain human readable format (boost::unit_test::OF_CLF)
0085 /// - XML format (boost::unit_test::OF_XML)
0086 /// @param[in] of one of the presefined enumeration values for output formats
0087 BOOST_TEST_DECL void    set_format( output_format of );
0088 
0089 /// Sets custom report formatter
0090 
0091 /// The framework takes ownership of the pointer passed as an argument. So this should be a pointer to
0092 /// a heap allocated object
0093 /// @param[in] f pointer to heap allocated instance of custom report formatter class
0094 BOOST_TEST_DECL void    set_format( results_reporter::format* f );
0095 
0096 /// @brief Access to configured results reporter stream
0097 ///
0098 /// Use this stream to report additional information abut test module execution
0099 BOOST_TEST_DECL std::ostream& get_stream();
0100 
0101 /// @}
0102 
0103 // ************************************************************************** //
0104 // **************               report initiation              ************** //
0105 // ************************************************************************** //
0106 
0107 BOOST_TEST_DECL void    make_report( report_level l = INV_REPORT_LEVEL, test_unit_id = INV_TEST_UNIT_ID );
0108 inline void             confirmation_report( test_unit_id id = INV_TEST_UNIT_ID )
0109 { make_report( CONFIRMATION_REPORT, id ); }
0110 inline void             short_report( test_unit_id id = INV_TEST_UNIT_ID )
0111 { make_report( SHORT_REPORT, id ); }
0112 inline void             detailed_report( test_unit_id id = INV_TEST_UNIT_ID )
0113 { make_report( DETAILED_REPORT, id ); }
0114 
0115 } // namespace results_reporter
0116 } // namespace unit_test
0117 } // namespace boost
0118 
0119 #include <boost/test/detail/enable_warnings.hpp>
0120 
0121 #endif // BOOST_TEST_RESULTS_REPORTER_HPP_021205GER
0122