1 //  (C) Copyright Gennadiy Rozental 2003-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: unit_test_log_formatter.hpp,v $
9 //
10 //  Version     : $Revision: 1.1.1.1 $
11 //
12 //  Description :
13 // ***************************************************************************
14 
15 #ifndef BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
16 #define BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
17 
18 // Boost.Test
19 #include <boost/test/detail/global_typedef.hpp>
20 #include <boost/test/detail/log_level.hpp>
21 #include <boost/test/detail/fwd_decl.hpp>
22 
23 // STL
24 #include <iosfwd>
25 #include <string> // for std::string
26 
27 #include <boost/test/detail/suppress_warnings.hpp>
28 
29 //____________________________________________________________________________//
30 
31 namespace boost {
32 
33 namespace unit_test {
34 
35 // ************************************************************************** //
36 // **************                log_entry_data                ************** //
37 // ************************************************************************** //
38 
39 struct log_entry_data {
40     std::string     m_file;
41     std::size_t     m_line;
42     log_level       m_level;
43 
clearboost::unit_test::log_entry_data44     void clear()
45     {
46         m_file    = std::string();
47         m_line    = 0;
48         m_level   = log_nothing;
49     }
50 };
51 
52 // ************************************************************************** //
53 // **************                checkpoint_data               ************** //
54 // ************************************************************************** //
55 
56 struct log_checkpoint_data
57 {
58     std::string     m_file;
59     std::size_t     m_line;
60     std::string     m_message;
61 
clearboost::unit_test::log_checkpoint_data62     void clear()
63     {
64         m_file    = std::string();
65         m_line    = 0;
66         m_message = std::string();
67     }
68 };
69 
70 // ************************************************************************** //
71 // **************            unit_test_log_formatter           ************** //
72 // ************************************************************************** //
73 
74 class unit_test_log_formatter {
75 public:
76     enum log_entry_types { BOOST_UTL_ET_INFO,
77                            BOOST_UTL_ET_MESSAGE,
78                            BOOST_UTL_ET_WARNING,
79                            BOOST_UTL_ET_ERROR,
80                            BOOST_UTL_ET_FATAL_ERROR };
81 
82     // Destructor
~unit_test_log_formatter()83     virtual             ~unit_test_log_formatter() {}
84 
85     // Formatter interface
86     virtual void        log_start( std::ostream&, counter_t test_cases_amount ) = 0;
87     virtual void        log_finish( std::ostream& ) = 0;
88     virtual void        log_build_info( std::ostream& ) = 0;
89 
90     virtual void        test_unit_start( std::ostream&, test_unit const& tu ) = 0;
91     virtual void        test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) = 0;
92     virtual void        test_unit_skipped( std::ostream&, test_unit const& ) = 0;
93 
94     virtual void        log_exception( std::ostream&, log_checkpoint_data const&, const_string explanation ) = 0;
95 
96     virtual void        log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) = 0;
97     virtual void        log_entry_value( std::ostream&, const_string value ) = 0;
98     virtual void        log_entry_finish( std::ostream& ) = 0;
99 };
100 
101 } // namespace unit_test
102 
103 } // namespace boost
104 
105 //____________________________________________________________________________//
106 
107 #include <boost/test/detail/enable_warnings.hpp>
108 
109 // ***************************************************************************
110 //  Revision History :
111 //
112 //  $Log: unit_test_log_formatter.hpp,v $
113 //  Revision 1.1.1.1  2006/03/20 20:15:27  ewalkup
114 //  boost libraries
115 //
116 //  Revision 1.13  2005/02/20 08:27:06  rogeeff
117 //  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
118 //
119 //  Revision 1.12  2005/02/01 08:59:28  rogeeff
120 //  supplied_log_formatters split
121 //  change formatters interface to simplify result interface
122 //
123 //  Revision 1.11  2005/02/01 06:40:06  rogeeff
124 //  copyright update
125 //  old log entries removed
126 //  minor stilistic changes
127 //  depricated tools removed
128 //
129 //  Revision 1.10  2005/01/30 03:23:58  rogeeff
130 //  counter type renamed
131 //  log interface slightly shortened
132 //
133 //  Revision 1.9  2005/01/21 07:30:24  rogeeff
134 //  to log testing time log formatter interfaces changed
135 //
136 //  Revision 1.8  2005/01/18 08:26:12  rogeeff
137 //  unit_test_log rework:
138 //     eliminated need for ::instance()
139 //     eliminated need for << end and ...END macro
140 //     straitend interface between log and formatters
141 //     change compiler like formatter name
142 //     minimized unit_test_log interface and reworked to use explicit calls
143 //
144 // ***************************************************************************
145 
146 #endif // BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER
147 
148