123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
- #define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER
- #include <boost/test/utils/class_properties.hpp>
- #include <boost/test/utils/wrap_stringstream.hpp>
- #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
- #include <boost/shared_ptr.hpp>
- #include <boost/detail/workaround.hpp>
- #include <cstddef> // for std::size_t
- #include <boost/test/detail/suppress_warnings.hpp>
- namespace boost {
- namespace test_tools {
- class BOOST_TEST_DECL assertion_result {
-
- typedef unit_test::const_string const_string;
-
- struct dummy { void nonnull() {} };
-
- typedef void (dummy::*safe_bool)();
- public:
-
- assertion_result( bool pv_ )
- : p_predicate_value( pv_ )
- {}
- template<typename BoolConvertable>
- assertion_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {}
-
- bool operator!() const { return !p_predicate_value; }
- void operator=( bool pv_ ) { p_predicate_value.value = pv_; }
- operator safe_bool() const { return !!p_predicate_value ? &dummy::nonnull : 0; }
-
- BOOST_READONLY_PROPERTY( bool, (assertion_result) ) p_predicate_value;
-
- bool has_empty_message() const { return !m_message; }
- wrap_stringstream& message()
- {
- if( !m_message )
- m_message.reset( new wrap_stringstream );
- return *m_message;
- }
- const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); }
- private:
-
- shared_ptr<wrap_stringstream> m_message;
- };
- typedef assertion_result predicate_result;
- }
- }
- #include <boost/test/detail/enable_warnings.hpp>
- #endif
|