sl@0
|
1 |
// (C) Copyright Gennadiy Rozental 2001-2005.
|
sl@0
|
2 |
// Distributed under the Boost Software License, Version 1.0.
|
sl@0
|
3 |
// (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
4 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
5 |
|
sl@0
|
6 |
// See http://www.boost.org/libs/test for the library home page.
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// File : $RCSfile: predicate_result.hpp,v $
|
sl@0
|
9 |
//
|
sl@0
|
10 |
// Version : $Revision: 1.7 $
|
sl@0
|
11 |
//
|
sl@0
|
12 |
// Description : enhanced result for test predicate that include message explaining failure
|
sl@0
|
13 |
// ***************************************************************************
|
sl@0
|
14 |
|
sl@0
|
15 |
#ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|
sl@0
|
16 |
#define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|
sl@0
|
17 |
|
sl@0
|
18 |
// Boost.Test
|
sl@0
|
19 |
#include <boost/test/utils/class_properties.hpp>
|
sl@0
|
20 |
#include <boost/test/utils/wrap_stringstream.hpp>
|
sl@0
|
21 |
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
sl@0
|
22 |
|
sl@0
|
23 |
// Boost
|
sl@0
|
24 |
#include <boost/shared_ptr.hpp>
|
sl@0
|
25 |
#include <boost/detail/workaround.hpp>
|
sl@0
|
26 |
|
sl@0
|
27 |
// STL
|
sl@0
|
28 |
#include <cstddef> // for std::size_t
|
sl@0
|
29 |
|
sl@0
|
30 |
#include <boost/test/detail/suppress_warnings.hpp>
|
sl@0
|
31 |
|
sl@0
|
32 |
//____________________________________________________________________________//
|
sl@0
|
33 |
|
sl@0
|
34 |
namespace boost {
|
sl@0
|
35 |
|
sl@0
|
36 |
namespace test_tools {
|
sl@0
|
37 |
|
sl@0
|
38 |
// ************************************************************************** //
|
sl@0
|
39 |
// ************** predicate_result ************** //
|
sl@0
|
40 |
// ************************************************************************** //
|
sl@0
|
41 |
|
sl@0
|
42 |
class BOOST_TEST_DECL predicate_result {
|
sl@0
|
43 |
typedef unit_test::const_string const_string;
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
// Constructor
|
sl@0
|
46 |
predicate_result( bool pv_ )
|
sl@0
|
47 |
: p_predicate_value( pv_ )
|
sl@0
|
48 |
{}
|
sl@0
|
49 |
|
sl@0
|
50 |
template<typename BoolConvertable>
|
sl@0
|
51 |
predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
|
sl@0
|
52 |
|
sl@0
|
53 |
bool operator!() const { return !p_predicate_value; }
|
sl@0
|
54 |
void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
|
sl@0
|
55 |
|
sl@0
|
56 |
// Public properties
|
sl@0
|
57 |
BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value;
|
sl@0
|
58 |
|
sl@0
|
59 |
// Access methods
|
sl@0
|
60 |
bool has_empty_message() const { return !m_message; }
|
sl@0
|
61 |
wrap_stringstream& message()
|
sl@0
|
62 |
{
|
sl@0
|
63 |
if( !m_message )
|
sl@0
|
64 |
m_message.reset( new wrap_stringstream );
|
sl@0
|
65 |
|
sl@0
|
66 |
return *m_message;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); }
|
sl@0
|
69 |
|
sl@0
|
70 |
private:
|
sl@0
|
71 |
// Data members
|
sl@0
|
72 |
shared_ptr<wrap_stringstream> m_message;
|
sl@0
|
73 |
};
|
sl@0
|
74 |
|
sl@0
|
75 |
} // namespace test_tools
|
sl@0
|
76 |
|
sl@0
|
77 |
} // namespace boost
|
sl@0
|
78 |
|
sl@0
|
79 |
//____________________________________________________________________________//
|
sl@0
|
80 |
|
sl@0
|
81 |
#include <boost/test/detail/enable_warnings.hpp>
|
sl@0
|
82 |
|
sl@0
|
83 |
// ***************************************************************************
|
sl@0
|
84 |
// Revision History :
|
sl@0
|
85 |
//
|
sl@0
|
86 |
// $Log: predicate_result.hpp,v $
|
sl@0
|
87 |
// Revision 1.7 2005/12/14 05:16:49 rogeeff
|
sl@0
|
88 |
// dll support introduced
|
sl@0
|
89 |
//
|
sl@0
|
90 |
// Revision 1.6 2005/03/23 21:02:17 rogeeff
|
sl@0
|
91 |
// Sunpro CC 5.3 fixes
|
sl@0
|
92 |
//
|
sl@0
|
93 |
// Revision 1.5 2005/02/20 08:27:06 rogeeff
|
sl@0
|
94 |
// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
|
sl@0
|
95 |
//
|
sl@0
|
96 |
// Revision 1.4 2005/02/03 20:39:12 rogeeff
|
sl@0
|
97 |
// m_message zero init for sunpro
|
sl@0
|
98 |
//
|
sl@0
|
99 |
// Revision 1.3 2005/02/01 06:40:06 rogeeff
|
sl@0
|
100 |
// copyright update
|
sl@0
|
101 |
// old log entries removed
|
sl@0
|
102 |
// minor stilistic changes
|
sl@0
|
103 |
// depricated tools removed
|
sl@0
|
104 |
//
|
sl@0
|
105 |
// Revision 1.2 2005/01/31 20:07:19 rogeeff
|
sl@0
|
106 |
// Sunpro CC 5.3 workarounds
|
sl@0
|
107 |
//
|
sl@0
|
108 |
// Revision 1.1 2005/01/30 03:24:51 rogeeff
|
sl@0
|
109 |
// extended_predicate_result renamed ot predicate_result and moved into separate file
|
sl@0
|
110 |
//
|
sl@0
|
111 |
// ***************************************************************************
|
sl@0
|
112 |
|
sl@0
|
113 |
#endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
|