1 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
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/entire_input.hpp>
7 #include <boost/metaparse/is_error.hpp>
8 #include <boost/metaparse/start.hpp>
9 #include <boost/metaparse/get_result.hpp>
10 #include <boost/metaparse/one_char.hpp>
11 #include <boost/metaparse/get_message.hpp>
12
13 #include "common.hpp"
14
15 #include <boost/mpl/equal_to.hpp>
16 #include <boost/mpl/apply_wrap.hpp>
17 #include <boost/mpl/assert.hpp>
18
19 #include <boost/type_traits/is_same.hpp>
20
21 #include "test_case.hpp"
22
BOOST_METAPARSE_TEST_CASE(entire_input)23 BOOST_METAPARSE_TEST_CASE(entire_input)
24 {
25 using boost::metaparse::get_result;
26 using boost::metaparse::entire_input;
27 using boost::metaparse::start;
28 using boost::metaparse::is_error;
29 using boost::metaparse::one_char;
30 using boost::metaparse::get_message;
31
32 using boost::mpl::equal_to;
33 using boost::mpl::apply_wrap2;
34
35 using boost::is_same;
36
37 typedef entire_input<one_char> ei;
38
39 // test_accept_entire_input
40 BOOST_MPL_ASSERT((
41 equal_to<get_result<apply_wrap2<ei, str_h, start> >::type, char_h>
42 ));
43
44 // test_reject_non_entire_input
45 BOOST_MPL_ASSERT((is_error<apply_wrap2<ei, str_hello, start> >));
46
47 // test_predefined_error_message
48 BOOST_MPL_ASSERT((
49 is_same<
50 test_failure,
51 get_message<
52 apply_wrap2<entire_input<one_char, test_failure>, str_hello, start>
53 >::type
54 >
55 ));
56 }
57
58