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/look_ahead.hpp> 7 #include <boost/metaparse/start.hpp> 8 #include <boost/metaparse/get_result.hpp> 9 #include <boost/metaparse/digit_val.hpp> 10 #include <boost/metaparse/fail.hpp> 11 #include <boost/metaparse/is_error.hpp> 12 #include <boost/metaparse/get_remaining.hpp> 13 14 #include "common.hpp" 15 16 #include <boost/mpl/apply_wrap.hpp> 17 #include <boost/mpl/equal_to.hpp> 18 #include <boost/mpl/equal.hpp> 19 #include <boost/mpl/assert.hpp> 20 21 #include "test_case.hpp" 22 BOOST_METAPARSE_TEST_CASE(look_ahead)23BOOST_METAPARSE_TEST_CASE(look_ahead) 24 { 25 26 using boost::metaparse::get_result; 27 using boost::metaparse::look_ahead; 28 using boost::metaparse::digit_val; 29 using boost::metaparse::start; 30 using boost::metaparse::is_error; 31 using boost::metaparse::fail; 32 using boost::metaparse::get_remaining; 33 34 using boost::mpl::equal_to; 35 using boost::mpl::apply_wrap2; 36 using boost::mpl::equal; 37 38 // test_returns_result 39 BOOST_MPL_ASSERT(( 40 equal_to< 41 int1, 42 get_result<apply_wrap2<look_ahead<digit_val>, str_1983, start> >::type 43 > 44 )); 45 46 // test_returns_error 47 BOOST_MPL_ASSERT(( 48 is_error<apply_wrap2<look_ahead<fail<int13> >, str_1983, start> > 49 )); 50 51 // test_doesnt_process_input 52 BOOST_MPL_ASSERT(( 53 equal< 54 str_1983, 55 get_remaining<apply_wrap2<look_ahead<digit_val>, str_1983, start> >::type 56 > 57 )); 58 } 59 60 61