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