File indexing completed on 2025-01-18 09:52:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
0013 #define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
0014
0015
0016 #include <boost/test/utils/class_properties.hpp>
0017 #include <boost/test/utils/wrap_stringstream.hpp>
0018 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
0019
0020
0021 #include <boost/shared_ptr.hpp>
0022 #include <boost/detail/workaround.hpp>
0023
0024
0025 #include <cstddef> // for std::size_t
0026
0027 #include <boost/test/detail/suppress_warnings.hpp>
0028
0029
0030
0031 namespace boost {
0032 namespace test_tools {
0033
0034
0035
0036
0037
0038
0039 class BOOST_TEST_DECL assertion_result {
0040
0041
0042 typedef unit_test::const_string const_string;
0043
0044
0045 struct dummy { void nonnull() {} };
0046
0047
0048 typedef void (dummy::*safe_bool)();
0049
0050 public:
0051
0052 assertion_result( bool pv_ )
0053 : p_predicate_value( pv_ )
0054 {}
0055
0056 template<typename BoolConvertable>
0057 assertion_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
0058
0059
0060 bool operator!() const { return !p_predicate_value; }
0061 void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
0062 operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
0063
0064
0065 BOOST_READONLY_PROPERTY( bool, (assertion_result) ) p_predicate_value;
0066
0067
0068 bool has_empty_message() const { return !m_message; }
0069 wrap_stringstream& message()
0070 {
0071 if( !m_message )
0072 m_message.reset( new wrap_stringstream );
0073
0074 return *m_message;
0075 }
0076 const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); }
0077
0078 private:
0079
0080 shared_ptr<wrap_stringstream> m_message;
0081 };
0082
0083 typedef assertion_result predicate_result;
0084
0085 }
0086 }
0087
0088 #include <boost/test/detail/enable_warnings.hpp>
0089
0090 #endif