| 1 | // Copyright Abel Sinkovics (abel@sinkovics.hu) 2010. |
| 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/is_error.hpp> |
| 7 | #include <boost/metaparse/start.hpp> |
| 8 | #include <boost/metaparse/get_result.hpp> |
| 9 | #include <boost/metaparse/get_remaining.hpp> |
| 10 | #include <boost/metaparse/get_position.hpp> |
| 11 | #include <boost/metaparse/get_message.hpp> |
| 12 | #include <boost/metaparse/error/literal_expected.hpp> |
| 13 | |
| 14 | #include "common.hpp" |
| 15 | |
| 16 | #include <boost/mpl/equal_to.hpp> |
| 17 | #include <boost/mpl/apply_wrap.hpp> |
| 18 | #include <boost/mpl/assert.hpp> |
| 19 | |
| 20 | #include <boost/type_traits/is_same.hpp> |
| 21 | |
| 22 | #include "test_case.hpp" |
| 23 | |
| 24 | BOOST_METAPARSE_TEST_CASE(lit_c) |
| 25 | { |
| 26 | using boost::metaparse::get_result; |
| 27 | using boost::metaparse::start; |
| 28 | using boost::metaparse::is_error; |
| 29 | using boost::metaparse::get_remaining; |
| 30 | using boost::metaparse::get_position; |
| 31 | using boost::metaparse::get_message; |
| 32 | |
| 33 | using boost::metaparse::error::literal_expected; |
| 34 | |
| 35 | using boost::mpl::equal_to; |
| 36 | using boost::mpl::apply_wrap2; |
| 37 | |
| 38 | using boost::is_same; |
| 39 | |
| 40 | // test_accept |
| 41 | BOOST_MPL_ASSERT(( |
| 42 | equal_to<get_result<apply_wrap2<lit_c_h, str_hello, start> >::type, char_h> |
| 43 | )); |
| 44 | |
| 45 | // test_reject |
| 46 | BOOST_MPL_ASSERT((is_error<apply_wrap2<lit_c_h, str_bello, start> >)); |
| 47 | |
| 48 | // test_with_empty_string |
| 49 | BOOST_MPL_ASSERT((is_error< apply_wrap2<lit_c_h, str_, start> >)); |
| 50 | |
| 51 | // test_error_with_empty_string |
| 52 | BOOST_MPL_ASSERT(( |
| 53 | is_same< |
| 54 | literal_expected<'h'>, |
| 55 | get_message<apply_wrap2<lit_c_h, str_, start> >::type |
| 56 | > |
| 57 | )); |
| 58 | |
| 59 | // test_remaining_string |
| 60 | BOOST_MPL_ASSERT(( |
| 61 | equal_to< |
| 62 | get_result< |
| 63 | apply_wrap2< |
| 64 | lit_c_e, |
| 65 | get_remaining<apply_wrap2<lit_c_h, str_hello, start> >::type, |
| 66 | get_position<apply_wrap2<lit_c_h, str_hello, start> >::type |
| 67 | > |
| 68 | >::type, |
| 69 | char_e |
| 70 | > |
| 71 | )); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | |