• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/return_.hpp>
7 #include <boost/metaparse/start.hpp>
8 #include <boost/metaparse/get_result.hpp>
9 #include <boost/metaparse/get_remaining.hpp>
10 #include <boost/metaparse/get_position.hpp>
11 
12 #include "common.hpp"
13 
14 #include <boost/mpl/equal_to.hpp>
15 #include <boost/mpl/apply_wrap.hpp>
16 #include <boost/mpl/assert.hpp>
17 
18 #include "test_case.hpp"
19 
20 namespace
21 {
22   using boost::metaparse::return_;
23 
24   using boost::mpl::apply_wrap2;
25 
26   typedef apply_wrap2<return_<int1>, int2, int3> acc;
27 
28   typedef return_<char_x> return_x;
29 }
30 
BOOST_METAPARSE_TEST_CASE(return)31 BOOST_METAPARSE_TEST_CASE(return)
32 {
33   using boost::metaparse::get_result;
34   using boost::metaparse::get_remaining;
35   using boost::metaparse::get_position;
36   using boost::metaparse::start;
37 
38   using boost::mpl::equal_to;
39 
40   // test_for_non_empty_string
41   BOOST_MPL_ASSERT((
42     equal_to<get_result<apply_wrap2<return_x, str_hello, start> >::type, char_x>
43   ));
44 
45   // test_for_empty_string
46   BOOST_MPL_ASSERT((
47     equal_to<get_result<apply_wrap2<return_x, str_, start> >::type, char_x>
48   ));
49 
50 
51   // test_get_result
52   BOOST_MPL_ASSERT((equal_to<int1, get_result<acc>::type>));
53 
54   // test_get_remaining
55   BOOST_MPL_ASSERT((equal_to<int2, get_remaining<acc>::type>));
56 
57   // test_get_position
58   BOOST_MPL_ASSERT((equal_to<int3, get_position<acc>::type>));
59 }
60 
61 
62