1 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2014.
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 #include <boost/metaparse/reject.hpp>
7 #include <boost/metaparse/start.hpp>
8 #include <boost/metaparse/get_message.hpp>
9 #include <boost/metaparse/get_position.hpp>
10
11 #include <boost/mpl/assert.hpp>
12
13 #include <boost/type_traits.hpp>
14
15 #include "test_case.hpp"
16
17 namespace
18 {
19 template <class T>
20 struct returns
21 {
22 typedef T type;
23 };
24
25 template <class T>
26 struct get_foo
27 {
28 typedef typename T::foo type;
29 };
30 }
31
BOOST_METAPARSE_TEST_CASE(reject)32 BOOST_METAPARSE_TEST_CASE(reject)
33 {
34 using boost::metaparse::reject;
35 using boost::metaparse::start;
36 using boost::metaparse::get_message;
37 using boost::metaparse::get_position;
38
39 using boost::is_same;
40
41 // test_reject_is_metaprogramming_value
42 BOOST_MPL_ASSERT((is_same<reject<int, start>, reject<int, start>::type>));
43
44 // test_reject_is_not_lazy
45 BOOST_MPL_ASSERT((
46 is_same<
47 reject<get_foo<int>, start>,
48 reject<get_foo<int>, returns<start> >::type
49 >
50 ));
51
52 // test_get_message_of_reject
53 BOOST_MPL_ASSERT((is_same<int, get_message<reject<int, start> >::type>));
54
55 // test_get_position_of_reject
56 BOOST_MPL_ASSERT((is_same<start, get_position<reject<int, start> >::type>));
57 }
58
59