1 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
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/one_of_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 
17 #include "test_case.hpp"
18 
BOOST_METAPARSE_TEST_CASE(one_of_c)19 BOOST_METAPARSE_TEST_CASE(one_of_c)
20 {
21   using boost::metaparse::is_error;
22   using boost::metaparse::one_of_c;
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   // test0
30   BOOST_MPL_ASSERT((is_error<apply_wrap2<one_of_c< >, str_hello, start> >));
31 
32   // test_1_with_good
33   BOOST_MPL_ASSERT((
34     equal_to<
35       get_result<apply_wrap2<one_of_c<'h'>, str_hello, start> >::type,
36       char_h
37     >
38   ));
39 
40   // test_1_with_bad
41   BOOST_MPL_ASSERT((
42     is_error<apply_wrap2<one_of_c<'x'>, str_hello, start> >
43   ));
44 
45   // test_2_with_two_good
46   BOOST_MPL_ASSERT((
47     equal_to<
48       get_result<apply_wrap2<one_of_c<'h', 'x'>, str_hello, start> >::type,
49       char_h
50     >
51   ));
52 
53   // test_2_with_first_good
54   BOOST_MPL_ASSERT((
55     equal_to<
56       get_result<apply_wrap2<one_of_c<'h', 'x'>, str_hello, start> >::type,
57       char_h
58     >
59   ));
60 
61   // test_2_with_second_good
62   BOOST_MPL_ASSERT((
63     equal_to<
64       get_result<apply_wrap2<one_of_c<'x', 'h'>, str_hello, start> >::type,
65       char_h
66     >
67   ));
68 
69   // test_2_with_two_bad
70   BOOST_MPL_ASSERT((
71     is_error<apply_wrap2<one_of_c<'x', 'y'>, str_hello, start> >
72   ));
73 }
74 
75 
76