Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:40

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 //  File        : $RCSfile$
0009 //
0010 //  Version     : $Revision: 74248 $
0011 //
0012 //  Description : inidiration interfaces to support manipulators and message output
0013 // ***************************************************************************
0014 
0015 #ifndef BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
0016 #define BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
0017 
0018 // Boost.Test
0019 #include <boost/test/tools/detail/fwd.hpp>
0020 
0021 #include <boost/test/tools/assertion_result.hpp>
0022 #include <boost/test/utils/lazy_ostream.hpp>
0023 
0024 #include <boost/shared_ptr.hpp>
0025 #include <list>
0026 
0027 #include <boost/test/detail/suppress_warnings.hpp>
0028 
0029 //____________________________________________________________________________//
0030 
0031 namespace boost {
0032 namespace test_tools {
0033 namespace tt_detail {
0034 
0035 struct assertion_evaluation_context 
0036 {
0037     assertion_evaluation_context(bool has_report = false)
0038     : m_has_report(has_report)
0039     {}
0040 
0041     bool m_has_report;
0042 };
0043 
0044 // ************************************************************************** //
0045 // **************        assertion_evaluate indirection        ************** //
0046 // ************************************************************************** //
0047 
0048 template<typename E>
0049 struct assertion_evaluate_t {
0050 
0051     typedef shared_ptr<assertion_evaluation_context> context_holder;
0052 
0053     assertion_evaluate_t( E const& e ) : m_e( e ), m_evaluate( true ) 
0054     {}
0055     
0056     operator assertion_result() { return m_e.evaluate( m_evaluate ); }
0057 
0058     assertion_evaluate_t<E> 
0059     stack_context(context_holder context) const {
0060         assertion_evaluate_t<E> added_context(*this);
0061     
0062         added_context.m_context_holder.push_back(context);
0063         added_context.m_evaluate = !context->m_has_report;
0064         return added_context;
0065     }
0066 
0067     E const& m_e;
0068     std::list< context_holder > m_context_holder;
0069     bool m_evaluate;
0070 };
0071 
0072 //____________________________________________________________________________//
0073 
0074 template<typename E>
0075 inline assertion_evaluate_t<E>
0076 assertion_evaluate( E const& e ) { return assertion_evaluate_t<E>( e ); }
0077 
0078 //____________________________________________________________________________//
0079 
0080 template<typename E, typename T>
0081 inline assertion_evaluate_t<E>
0082 operator<<( assertion_evaluate_t<E> const& ae, T const& ) { return ae; }
0083 
0084 //____________________________________________________________________________//
0085 
0086 // ************************************************************************** //
0087 // **************          assertion_text indirection          ************** //
0088 // ************************************************************************** //
0089 
0090 inline unit_test::lazy_ostream const&
0091 assertion_text( unit_test::lazy_ostream const& et, unit_test::lazy_ostream const& s) { 
0092     if(!s.empty())
0093         return s;
0094     return et; 
0095 }
0096 
0097 //____________________________________________________________________________//
0098 
0099 // ************************************************************************** //
0100 // **************        assertion_evaluate indirection        ************** //
0101 // ************************************************************************** //
0102 
0103 struct assertion_type {
0104     assertion_type(check_type ct = CHECK_MSG) : m_check_type(ct)
0105     {}
0106 
0107     operator check_type() { return m_check_type; }
0108     check_type m_check_type;
0109 };
0110 
0111 //____________________________________________________________________________//
0112 
0113 template<typename T>
0114 inline assertion_type
0115 operator<<( assertion_type const& at, T const& ) { return at; }
0116 
0117 //____________________________________________________________________________//
0118 
0119 } // namespace tt_detail
0120 } // namespace test_tools
0121 } // namespace boost
0122 
0123 #include <boost/test/detail/enable_warnings.hpp>
0124 
0125 #endif // BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER