blob: fe76eb67052f37bc483a85ea2ef150487e8900b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
// (C) Copyright Gennadiy Rozental 2001-2008.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/test for the library home page.
//
// File : $RCSfile$
//
// Version : $Revision: 54633 $
//
// Description : defines singleton class unit_test_log and all manipulators.
// unit_test_log has output stream like interface. It's implementation is
// completely hidden with pimple idiom
// ***************************************************************************
#ifndef BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
#define BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
// Boost.Test
#include <boost/test/test_observer.hpp>
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/detail/log_level.hpp>
#include <boost/test/detail/fwd_decl.hpp>
#include <boost/test/utils/wrap_stringstream.hpp>
#include <boost/test/utils/trivial_singleton.hpp>
#include <boost/test/utils/lazy_ostream.hpp>
// Boost
#include <boost/utility.hpp>
// STL
#include <iosfwd> // for std::ostream&
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
namespace boost {
namespace unit_test {
// ************************************************************************** //
// ************** log manipulators ************** //
// ************************************************************************** //
namespace log {
struct BOOST_TEST_DECL begin {
begin( const_string fn, std::size_t ln )
: m_file_name( fn )
, m_line_num( ln )
{}
const_string m_file_name;
std::size_t m_line_num;
};
struct end {};
} // namespace log
// ************************************************************************** //
// ************** entry_value_collector ************** //
// ************************************************************************** //
namespace ut_detail {
class BOOST_TEST_DECL entry_value_collector {
public:
// Constructors
entry_value_collector() : m_last( true ) {}
entry_value_collector( entry_value_collector const& rhs ) : m_last( true ) { rhs.m_last = false; }
~entry_value_collector();
// collection interface
entry_value_collector const& operator<<( lazy_ostream const& ) const;
entry_value_collector const& operator<<( const_string ) const;
private:
// Data members
mutable bool m_last;
};
} // namespace ut_detail
// ************************************************************************** //
// ************** unit_test_log ************** //
// ************************************************************************** //
class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton<unit_test_log_t> {
public:
// test_observer interface implementation
void test_start( counter_t test_cases_amount );
void test_finish();
void test_aborted();
void test_unit_start( test_unit const& );
void test_unit_finish( test_unit const&, unsigned long elapsed );
void test_unit_skipped( test_unit const& );
void test_unit_aborted( test_unit const& );
void assertion_result( bool passed );
void exception_caught( execution_exception const& );
virtual int priority() { return 1; }
// log configuration methods
void set_stream( std::ostream& );
void set_threshold_level( log_level );
void set_format( output_format );
void set_formatter( unit_test_log_formatter* );
// test progress logging
void set_checkpoint( const_string file, std::size_t line_num, const_string msg = const_string() );
// entry logging
unit_test_log_t& operator<<( log::begin const& ); // begin entry
unit_test_log_t& operator<<( log::end const& ); // end entry
unit_test_log_t& operator<<( log_level ); // set entry level
unit_test_log_t& operator<<( const_string ); // log entry value
unit_test_log_t& operator<<( lazy_ostream const& ); // log entry value
ut_detail::entry_value_collector operator()( log_level ); // initiate entry collection
private:
bool log_entry_start();
BOOST_TEST_SINGLETON_CONS( unit_test_log_t );
}; // unit_test_log_t
BOOST_TEST_SINGLETON_INST( unit_test_log )
// helper macros
#define BOOST_TEST_LOG_ENTRY( ll ) \
(::boost::unit_test::unit_test_log \
<< ::boost::unit_test::log::begin( BOOST_TEST_L(__FILE__), __LINE__ ))(ll) \
/**/
} // namespace unit_test
} // namespace boost
// ************************************************************************** //
// ************** Unit test log interface helpers ************** //
// ************************************************************************** //
#define BOOST_TEST_MESSAGE( M ) \
BOOST_TEST_LOG_ENTRY( ::boost::unit_test::log_messages ) \
<< (::boost::unit_test::lazy_ostream::instance() << M) \
/**/
//____________________________________________________________________________//
#define BOOST_TEST_PASSPOINT() \
::boost::unit_test::unit_test_log.set_checkpoint( \
BOOST_TEST_L(__FILE__), \
static_cast<std::size_t>(__LINE__) ) \
/**/
//____________________________________________________________________________//
#define BOOST_TEST_CHECKPOINT( M ) \
::boost::unit_test::unit_test_log.set_checkpoint( \
BOOST_TEST_L(__FILE__), \
static_cast<std::size_t>(__LINE__), \
(::boost::wrap_stringstream().ref() << M).str() ) \
/**/
//____________________________________________________________________________//
#include <boost/test/detail/enable_warnings.hpp>
#endif // BOOST_TEST_UNIT_TEST_LOG_HPP_071894GER
|