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/int_.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 
17 #include "test_case.hpp"
18 
BOOST_METAPARSE_TEST_CASE(int)19 BOOST_METAPARSE_TEST_CASE(int)
20 {
21   using boost::metaparse::is_error;
22   using boost::metaparse::int_;
23   using boost::metaparse::start;
24   using boost::metaparse::get_result;
25 
26   using boost::mpl::apply_wrap2;
27   using boost::mpl::equal_to;
28 
29   // test_with_text
30   BOOST_MPL_ASSERT((is_error<apply_wrap2<int_, str_hello, start> >));
31 
32   // test_with_zero
33   BOOST_MPL_ASSERT((
34     equal_to<get_result<apply_wrap2<int_, str_0, start> >::type, int0>
35   ));
36 
37   // test_with_one_digit
38   BOOST_MPL_ASSERT((
39     equal_to<get_result<apply_wrap2<int_, str_1, start> >::type, int1>
40   ));
41 
42   // test_with_big_number
43   BOOST_MPL_ASSERT((
44     equal_to<
45       get_result<apply_wrap2<int_, str_1983, start> >::type,
46       boost::mpl::int_<1983>
47     >
48   ));
49 
50   // test_with_empty_string
51   BOOST_MPL_ASSERT((is_error<apply_wrap2<int_, str_, start> >));
52 }
53 
54