context.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 : test tools context interfaces
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
  14. #define BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
  15. // Boost.Test
  16. #include <boost/test/utils/lazy_ostream.hpp>
  17. #include <boost/test/detail/pp_variadic.hpp>
  18. #include <boost/preprocessor/repetition/enum_params.hpp>
  19. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  20. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  21. #include <boost/preprocessor/variadic/to_seq.hpp>
  22. #include <boost/preprocessor/variadic/size.hpp>
  23. #include <boost/preprocessor/cat.hpp>
  24. #include <boost/preprocessor/seq/for_each_i.hpp>
  25. #include <boost/preprocessor/seq/for_each.hpp>
  26. #include <boost/preprocessor/seq/enum.hpp>
  27. #include <boost/preprocessor/control/iif.hpp>
  28. #include <boost/preprocessor/comparison/equal.hpp>
  29. #include <boost/test/detail/suppress_warnings.hpp>
  30. //____________________________________________________________________________//
  31. namespace boost {
  32. namespace test_tools {
  33. namespace tt_detail {
  34. // ************************************************************************** //
  35. // ************** context_frame ************** //
  36. // ************************************************************************** //
  37. struct BOOST_TEST_DECL context_frame {
  38. explicit context_frame( ::boost::unit_test::lazy_ostream const& context_descr );
  39. ~context_frame();
  40. operator bool();
  41. private:
  42. // Data members
  43. int m_frame_id;
  44. };
  45. //____________________________________________________________________________//
  46. #define BOOST_TEST_INFO( context_descr ) \
  47. ::boost::unit_test::framework::add_context( BOOST_TEST_LAZY_MSG( context_descr ) , false ) \
  48. /**/
  49. #define BOOST_TEST_INFO_SCOPE( context_descr ) \
  50. ::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) = \
  51. ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) \
  52. /**/
  53. //____________________________________________________________________________//
  54. #define BOOST_CONTEXT_PARAM(r, ctx, i, context_descr) \
  55. if( ::boost::test_tools::tt_detail::context_frame BOOST_PP_CAT(ctx, i) = \
  56. ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) ) \
  57. /**/
  58. #define BOOST_CONTEXT_PARAMS( params ) \
  59. BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONTEXT_PARAM, \
  60. BOOST_JOIN( context_frame_, __LINE__ ), \
  61. params) \
  62. /**/
  63. #define BOOST_TEST_CONTEXT( ... ) \
  64. BOOST_CONTEXT_PARAMS( BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) ) \
  65. /**/
  66. //____________________________________________________________________________//
  67. } // namespace tt_detail
  68. } // namespace test_tools
  69. } // namespace boost
  70. #include <boost/test/detail/enable_warnings.hpp>
  71. #endif // BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER