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 
6 //  See http://www.boost.org/libs/test for the library home page.
7 //
8 //  File        : $RCSfile$
9 //
10 //  Version     : $Revision: 74248 $
11 //
12 //  Description : test tools context interfaces
13 // ***************************************************************************
14 
15 #ifndef BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
16 #define BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
17 
18 // Boost.Test
19 #include <boost/test/utils/lazy_ostream.hpp>
20 #include <boost/test/detail/pp_variadic.hpp>
21 
22 #include <boost/preprocessor/repetition/enum_params.hpp>
23 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
24 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
25 
26 #include <boost/preprocessor/variadic/to_seq.hpp>
27 #include <boost/preprocessor/variadic/size.hpp>
28 #include <boost/preprocessor/cat.hpp>
29 #include <boost/preprocessor/seq/for_each_i.hpp>
30 #include <boost/preprocessor/seq/for_each.hpp>
31 #include <boost/preprocessor/seq/enum.hpp>
32 #include <boost/preprocessor/control/iif.hpp>
33 #include <boost/preprocessor/comparison/equal.hpp>
34 
35 #include <boost/test/detail/suppress_warnings.hpp>
36 
37 //____________________________________________________________________________//
38 
39 namespace boost {
40 namespace test_tools {
41 namespace tt_detail {
42 
43 // ************************************************************************** //
44 // **************                 context_frame                ************** //
45 // ************************************************************************** //
46 
47 struct BOOST_TEST_DECL context_frame {
48     explicit    context_frame( ::boost::unit_test::lazy_ostream const& context_descr );
49     ~context_frame();
50 
51     operator    bool();
52 
53 private:
54     // Data members
55     int         m_frame_id;
56 };
57 
58 //____________________________________________________________________________//
59 
60 #define BOOST_TEST_INFO( context_descr )                                                        \
61     ::boost::unit_test::framework::add_context( BOOST_TEST_LAZY_MSG( context_descr ) , false )  \
62 /**/
63 
64 #define BOOST_TEST_INFO_SCOPE( context_descr )                                                 \
65     ::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) =      \
66        ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) )     \
67 /**/
68 
69 //____________________________________________________________________________//
70 
71 
72 #define BOOST_CONTEXT_PARAM(r, ctx, i, context_descr)  \
73   if( ::boost::test_tools::tt_detail::context_frame BOOST_PP_CAT(ctx, i) =                       \
74         ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) )   \
75 /**/
76 
77 #define BOOST_CONTEXT_PARAMS( params )                                                           \
78         BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONTEXT_PARAM,                                             \
79                                 BOOST_JOIN( context_frame_, __LINE__ ),                          \
80                                 params)                                                          \
81 /**/
82 
83 #define BOOST_TEST_CONTEXT( ... )                                                                \
84     BOOST_CONTEXT_PARAMS(  BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) )                               \
85 /**/
86 
87 
88 //____________________________________________________________________________//
89 
90 } // namespace tt_detail
91 } // namespace test_tools
92 } // namespace boost
93 
94 #include <boost/test/detail/enable_warnings.hpp>
95 
96 #endif // BOOST_TEST_TOOLS_CONTEXT_HPP_111712GER
97