sl@0: // (C) Copyright Gennadiy Rozental 2001-2005. sl@0: // Distributed under the Boost Software License, Version 1.0. sl@0: // (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // See http://www.boost.org/libs/test for the library home page. sl@0: // sl@0: // File : $RCSfile: predicate_result.hpp,v $ sl@0: // sl@0: // Version : $Revision: 1.7 $ sl@0: // sl@0: // Description : enhanced result for test predicate that include message explaining failure sl@0: // *************************************************************************** sl@0: sl@0: #ifndef BOOST_TEST_PREDICATE_RESULT_HPP_012705GER sl@0: #define BOOST_TEST_PREDICATE_RESULT_HPP_012705GER sl@0: sl@0: // Boost.Test sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: // Boost sl@0: #include sl@0: #include sl@0: sl@0: // STL sl@0: #include // for std::size_t sl@0: sl@0: #include sl@0: sl@0: //____________________________________________________________________________// sl@0: sl@0: namespace boost { sl@0: sl@0: namespace test_tools { sl@0: sl@0: // ************************************************************************** // sl@0: // ************** predicate_result ************** // sl@0: // ************************************************************************** // sl@0: sl@0: class BOOST_TEST_DECL predicate_result { sl@0: typedef unit_test::const_string const_string; sl@0: public: sl@0: // Constructor sl@0: predicate_result( bool pv_ ) sl@0: : p_predicate_value( pv_ ) sl@0: {} sl@0: sl@0: template sl@0: predicate_result( BoolConvertable const& pv_ ) : p_predicate_value( !!pv_ ) {} sl@0: sl@0: bool operator!() const { return !p_predicate_value; } sl@0: void operator=( bool pv_ ) { p_predicate_value.value = pv_; } sl@0: sl@0: // Public properties sl@0: BOOST_READONLY_PROPERTY( bool, (predicate_result) ) p_predicate_value; sl@0: sl@0: // Access methods sl@0: bool has_empty_message() const { return !m_message; } sl@0: wrap_stringstream& message() sl@0: { sl@0: if( !m_message ) sl@0: m_message.reset( new wrap_stringstream ); sl@0: sl@0: return *m_message; sl@0: } sl@0: const_string message() const { return !m_message ? const_string() : const_string( m_message->str() ); } sl@0: sl@0: private: sl@0: // Data members sl@0: shared_ptr m_message; sl@0: }; sl@0: sl@0: } // namespace test_tools sl@0: sl@0: } // namespace boost sl@0: sl@0: //____________________________________________________________________________// sl@0: sl@0: #include sl@0: sl@0: // *************************************************************************** sl@0: // Revision History : sl@0: // sl@0: // $Log: predicate_result.hpp,v $ sl@0: // Revision 1.7 2005/12/14 05:16:49 rogeeff sl@0: // dll support introduced sl@0: // sl@0: // Revision 1.6 2005/03/23 21:02:17 rogeeff sl@0: // Sunpro CC 5.3 fixes sl@0: // sl@0: // Revision 1.5 2005/02/20 08:27:06 rogeeff sl@0: // This a major update for Boost.Test framework. See release docs for complete list of fixes/updates sl@0: // sl@0: // Revision 1.4 2005/02/03 20:39:12 rogeeff sl@0: // m_message zero init for sunpro sl@0: // sl@0: // Revision 1.3 2005/02/01 06:40:06 rogeeff sl@0: // copyright update sl@0: // old log entries removed sl@0: // minor stilistic changes sl@0: // depricated tools removed sl@0: // sl@0: // Revision 1.2 2005/01/31 20:07:19 rogeeff sl@0: // Sunpro CC 5.3 workarounds sl@0: // sl@0: // Revision 1.1 2005/01/30 03:24:51 rogeeff sl@0: // extended_predicate_result renamed ot predicate_result and moved into separate file sl@0: // sl@0: // *************************************************************************** sl@0: sl@0: #endif // BOOST_TEST_PREDICATE_RESULT_HPP_012705GER