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/digit.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/get_message.hpp>
11 
12 #include <boost/metaparse/error/digit_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 "test_case.hpp"
21 
22 #include <boost/type_traits/is_same.hpp>
23 
BOOST_METAPARSE_TEST_CASE(digit)24 BOOST_METAPARSE_TEST_CASE(digit)
25 {
26   using boost::metaparse::is_error;
27   using boost::metaparse::digit;
28   using boost::metaparse::start;
29   using boost::metaparse::get_result;
30   using boost::metaparse::get_message;
31 
32   using boost::metaparse::error::digit_expected;
33 
34   using boost::mpl::apply_wrap2;
35   using boost::mpl::equal_to;
36 
37   using boost::is_same;
38 
39   // test_with_text
40   BOOST_MPL_ASSERT((is_error<apply_wrap2<digit, str_hello, start> >));
41 
42   // test_with_number
43   BOOST_MPL_ASSERT((
44     equal_to<get_result<apply_wrap2<digit, str_1983, start> >::type, char_1>
45   ));
46 
47   // test_with_empty_string
48   BOOST_MPL_ASSERT((is_error<apply_wrap2<digit, str_, start> >));
49 
50   // test_error_message_with_empty_string
51   BOOST_MPL_ASSERT((
52     is_same<digit_expected, get_message<apply_wrap2<digit, str_, start> >::type>
53   ));
54 }
55 
56