]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/proto/test/make.cpp
1 ///////////////////////////////////////////////////////////////////////////////
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/proto/core.hpp>
9 #include <boost/proto/transform/arg.hpp>
10 #include <boost/proto/transform/make.hpp>
11 #include <boost/mpl/identity.hpp>
12 #include <boost/test/unit_test.hpp>
14 namespace mpl
= boost::mpl
;
15 namespace proto
= boost::proto
;
25 explicit wrapper(T
const & t
= T()) : t_(t
) {}
31 typedef typename
T::not_there not_there
;
34 // Test that when no substitution is done, we don't instantiate templates
36 : proto::make
< type2type
< careful
<int> > >
41 proto::terminal
<int>::type i
= {42};
42 type2type
< careful
<int> > res
= MakeTest1()(i
);
45 // Test that when substitution is done, and there is no nested ::type
46 // typedef, the result is the wrapper
48 : proto::make
< wrapper
< proto::_value
> >
53 proto::terminal
<int>::type i
= {42};
54 wrapper
<int> res
= MakeTest2()(i
);
55 BOOST_CHECK_EQUAL(res
.t_
, 0);
58 // Test that when substitution is done, and there is no nested ::type
59 // typedef, the result is the wrapper
61 : proto::make
< wrapper
< proto::_value
>(proto::_value
) >
66 proto::terminal
<int>::type i
= {42};
67 wrapper
<int> res
= MakeTest3()(i
);
68 BOOST_CHECK_EQUAL(res
.t_
, 42);
71 // Test that when substitution is done, and there is no nested ::type
72 // typedef, the result is the wrapper
74 : proto::make
< mpl::identity
< proto::_value
>(proto::_value
) >
79 proto::terminal
<int>::type i
= {42};
80 int res
= MakeTest4()(i
);
81 BOOST_CHECK_EQUAL(res
, 42);
84 using namespace boost::unit_test
;
85 ///////////////////////////////////////////////////////////////////////////////
86 // init_unit_test_suite
88 test_suite
* init_unit_test_suite( int argc
, char* argv
[] )
90 test_suite
*test
= BOOST_TEST_SUITE("test the make transform");
92 test
->add(BOOST_TEST_CASE(&make_test1
));
93 test
->add(BOOST_TEST_CASE(&make_test2
));
94 test
->add(BOOST_TEST_CASE(&make_test3
));
95 test
->add(BOOST_TEST_CASE(&make_test4
));