• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // This header file contains code that is reused by other cpp files
7 
8 #include <boost/metaparse/letter.hpp>
9 #include <boost/metaparse/start.hpp>
10 #include <boost/metaparse/get_result.hpp>
11 #include <boost/metaparse/always.hpp>
12 #include <boost/metaparse/one_char.hpp>
13 
14 #include "common.hpp"
15 
16 #include <boost/mpl/apply_wrap.hpp>
17 #include <boost/mpl/equal.hpp>
18 #include <boost/mpl/equal_to.hpp>
19 #include <boost/mpl/size.hpp>
20 #include <boost/mpl/vector.hpp>
21 #include <boost/mpl/vector_c.hpp>
22 #include <boost/mpl/assert.hpp>
23 
24 #include "test_case.hpp"
25 
BOOST_METAPARSE_TEST_CASE(TEST_NAME)26 BOOST_METAPARSE_TEST_CASE(TEST_NAME)
27 {
28   using boost::metaparse::get_result;
29   using boost::metaparse::letter;
30   using boost::metaparse::start;
31   using boost::metaparse::one_char;
32   using boost::metaparse::always;
33 
34   using boost::mpl::equal;
35   using boost::mpl::equal_to;
36   using boost::mpl::apply_wrap2;
37   using boost::mpl::vector_c;
38   using boost::mpl::vector;
39   using boost::mpl::list;
40   using boost::mpl::size;
41 
42   typedef repeated<letter> repeated_letter;
43   typedef always<one_char, int> always_int;
44 
45   // test_empty_input
46   BOOST_MPL_ASSERT((
47     equal<get_result<apply_wrap2<repeated_letter, str_, start> >::type, list<> >
48   ));
49 
50   // test0
51   BOOST_MPL_ASSERT((
52     equal<
53       get_result<apply_wrap2<repeated_letter, chars0, start> >::type,
54       list<>
55     >
56   ));
57 
58   // test1
59   BOOST_MPL_ASSERT((
60     equal<
61       get_result<apply_wrap2<repeated_letter, chars1, start> >::type,
62       vector_c<char, 'h'>
63     >
64   ));
65 
66   // test2
67   BOOST_MPL_ASSERT((
68     equal<
69       get_result<apply_wrap2<repeated_letter, chars2, start> >::type,
70       vector_c<char, 'h', 'e'>
71     >
72   ));
73 
74   // test3
75   BOOST_MPL_ASSERT((
76     equal<
77       get_result<apply_wrap2<repeated_letter, chars3, start> >::type,
78       vector_c<char, 'h', 'e', 'l'>
79     >
80   ));
81 
82   // test4
83   BOOST_MPL_ASSERT((
84     equal<
85       get_result<apply_wrap2<repeated_letter, chars4, start> >::type,
86       vector_c<char, 'h', 'e', 'l', 'l'>
87     >
88   ));
89 
90   // test5
91   BOOST_MPL_ASSERT((
92     equal<
93       get_result<apply_wrap2<repeated_letter, chars5, start> >::type,
94       vector_c<char, 'h', 'e', 'l', 'l', 'o'>
95     >
96   ));
97 
98   // test_length
99   BOOST_MPL_ASSERT((
100     equal_to<
101       size<
102         get_result<apply_wrap2<repeated_letter, chars3, start> >::type
103       >::type,
104       int3
105     >
106   ));
107 
108   // test_no_extra_evaluation
109   BOOST_MPL_ASSERT((
110     equal<
111       get_result<apply_wrap2<repeated<always_int>, str_ca, start> >::type,
112       vector<int, int>
113     >
114   ));
115 }
116 
117 
118