• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/range_c.hpp>
7 #include <boost/metaparse/is_error.hpp>
8 #include <boost/metaparse/start.hpp>
9 #include <boost/metaparse/get_result.hpp>
10 
11 #include "common.hpp"
12 
13 #include <boost/mpl/equal_to.hpp>
14 #include <boost/mpl/apply_wrap.hpp>
15 #include <boost/mpl/assert.hpp>
16 #include <boost/mpl/char.hpp>
17 
18 #include "test_case.hpp"
19 
BOOST_METAPARSE_TEST_CASE(range_c)20 BOOST_METAPARSE_TEST_CASE(range_c)
21 {
22   using boost::metaparse::is_error;
23   using boost::metaparse::range_c;
24   using boost::metaparse::start;
25   using boost::metaparse::get_result;
26 
27   using boost::mpl::apply_wrap2;
28   using boost::mpl::equal_to;
29   using boost::mpl::char_;
30 
31   typedef range_c<'0', '9'> digit_range;
32 
33   // test_with_text
34   BOOST_MPL_ASSERT((is_error<apply_wrap2<digit_range, str_hello, start> >));
35 
36   // test_with_number
37   BOOST_MPL_ASSERT((
38     equal_to<
39       get_result<apply_wrap2<digit_range, str_1983, start> >::type,
40       char_1
41     >
42   ));
43 
44   // test_with_empty_string
45   BOOST_MPL_ASSERT((is_error<apply_wrap2<digit_range, str_, start> >));
46 }
47 
48