indirections.hpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 74248 $
  10. //
  11. // Description : inidiration interfaces to support manipulators and message output
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
  14. #define BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER
  15. // Boost.Test
  16. #include <boost/test/tools/detail/fwd.hpp>
  17. #include <boost/test/tools/assertion_result.hpp>
  18. #include <boost/test/detail/suppress_warnings.hpp>
  19. //____________________________________________________________________________//
  20. namespace boost {
  21. namespace test_tools {
  22. namespace tt_detail {
  23. // ************************************************************************** //
  24. // ************** assertion_evaluate indirection ************** //
  25. // ************************************************************************** //
  26. template<typename E>
  27. struct assertion_evaluate_t {
  28. assertion_evaluate_t( E const& e ) : m_e( e ) {}
  29. operator assertion_result() { return m_e.evaluate( true ); }
  30. E const& m_e;
  31. };
  32. //____________________________________________________________________________//
  33. template<typename E>
  34. inline assertion_evaluate_t<E>
  35. assertion_evaluate( E const& e ) { return assertion_evaluate_t<E>( e ); }
  36. //____________________________________________________________________________//
  37. template<typename E, typename T>
  38. inline assertion_evaluate_t<E>
  39. operator<<( assertion_evaluate_t<E> const& ae, T const& ) { return ae; }
  40. //____________________________________________________________________________//
  41. // ************************************************************************** //
  42. // ************** assertion_text indirection ************** //
  43. // ************************************************************************** //
  44. template<typename T>
  45. inline unit_test::lazy_ostream const&
  46. assertion_text( unit_test::lazy_ostream const& /*et*/, T const& m ) { return m; }
  47. //____________________________________________________________________________//
  48. inline unit_test::lazy_ostream const&
  49. assertion_text( unit_test::lazy_ostream const& et, int ) { return et; }
  50. //____________________________________________________________________________//
  51. // ************************************************************************** //
  52. // ************** assertion_evaluate indirection ************** //
  53. // ************************************************************************** //
  54. struct assertion_type {
  55. operator check_type() { return CHECK_MSG; }
  56. };
  57. //____________________________________________________________________________//
  58. template<typename T>
  59. inline assertion_type
  60. operator<<( assertion_type const& at, T const& ) { return at; }
  61. //____________________________________________________________________________//
  62. } // namespace tt_detail
  63. } // namespace test_tools
  64. } // namespace boost
  65. #include <boost/test/detail/enable_warnings.hpp>
  66. #endif // BOOST_TEST_TOOLS_DETAIL_INDIRECTIONS_HPP_112812GER