]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/test/sequence.cpp
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)
6 #include <boost/metaparse/sequence.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/always.hpp>
11 #include <boost/metaparse/one_char.hpp>
15 #include <boost/mpl/equal_to.hpp>
16 #include <boost/mpl/apply_wrap.hpp>
17 #include <boost/mpl/list.hpp>
18 #include <boost/mpl/at.hpp>
19 #include <boost/mpl/equal.hpp>
20 #include <boost/mpl/vector_c.hpp>
21 #include <boost/mpl/vector.hpp>
22 #include <boost/mpl/assert.hpp>
24 #include "test_case.hpp"
26 BOOST_METAPARSE_TEST_CASE(sequence
)
28 using boost::metaparse::get_result
;
29 using boost::metaparse::sequence
;
30 using boost::metaparse::start
;
31 using boost::metaparse::is_error
;
32 using boost::metaparse::always
;
33 using boost::metaparse::one_char
;
35 using boost::mpl::equal
;
36 using boost::mpl::apply_wrap2
;
37 using boost::mpl::list
;
38 using boost::mpl::equal_to
;
39 using boost::mpl::at_c
;
40 using boost::mpl::vector_c
;
41 using boost::mpl::vector
;
43 typedef always
<one_char
, int> always_int
;
47 equal
<get_result
<apply_wrap2
<sequence
<>, str_hello
, start
> >::type
, list
<> >
53 get_result
<apply_wrap2
<sequence
<lit_h
>, str_hello
, start
> >::type
,
58 // test_one_failing_parser
59 BOOST_MPL_ASSERT((is_error
<apply_wrap2
<sequence
<lit_e
>, str_hello
, start
> >));
64 get_result
<apply_wrap2
<sequence
<lit_h
, lit_e
>, str_hello
, start
> >::type
,
65 vector_c
<char, 'h', 'e'>
71 is_error
<apply_wrap2
<sequence
<lit_x
, lit_e
>, str_hello
, start
> >
76 is_error
<apply_wrap2
<sequence
<lit_h
, lit_x
>, str_hello
, start
> >
80 BOOST_MPL_ASSERT((is_error
<apply_wrap2
<sequence
<lit_h
,lit_e
>, str_
,start
> >));
86 apply_wrap2
<sequence
<lit_h
, lit_e
, lit_l
>, str_hello
, start
>
88 vector_c
<char, 'h', 'e', 'l'>
92 // test_indexing_in_result
97 apply_wrap2
<sequence
<lit_h
, lit_e
, lit_l
>, str_hello
, start
>
105 // test_no_extra_evaluation
109 apply_wrap2
<sequence
<always_int
, always_int
>, str_ca
, start
>