• 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/space.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/char.hpp>
16 #include <boost/mpl/assert.hpp>
17 
18 #include "test_case.hpp"
19 
20 namespace
21 {
22   using boost::mpl::list_c;
23 
24   typedef list_c<char, '\t', 'e', 'l', 'l', 'o'> str_with_t;
25   typedef list_c<char, '\n', 'e', 'l', 'l', 'o'> str_with_n;
26   typedef list_c<char, '\r', 'e', 'l', 'l', 'o'> str_with_r;
27 }
28 
BOOST_METAPARSE_TEST_CASE(space)29 BOOST_METAPARSE_TEST_CASE(space)
30 {
31   using boost::metaparse::is_error;
32   using boost::metaparse::space;
33   using boost::metaparse::start;
34   using boost::metaparse::get_result;
35 
36   using boost::mpl::apply_wrap2;
37   using boost::mpl::equal_to;
38   using boost::mpl::char_;
39 
40   // test_with_text
41   BOOST_MPL_ASSERT((is_error<apply_wrap2<space, str_hello, start> >));
42 
43   // test_with_space
44   BOOST_MPL_ASSERT((
45     equal_to<
46       get_result<apply_wrap2<space, str__ello, start> >::type,
47       char_<' '>
48     >
49   ));
50 
51   // test_with_tab
52   BOOST_MPL_ASSERT((
53     equal_to<
54       get_result<apply_wrap2<space, str_with_t, start> >::type,
55       char_<'\t'>
56     >
57   ));
58 
59   // test_with_line_feed
60   BOOST_MPL_ASSERT((
61     equal_to<
62       get_result<apply_wrap2<space, str_with_n, start> >::type,
63       char_<'\n'>
64     >
65   ));
66 
67   // test_with_c_return
68   BOOST_MPL_ASSERT((
69     equal_to<
70       get_result<apply_wrap2<space, str_with_r, start> >::type,
71       char_<'\r'>
72     >
73   ));
74 
75   // test_with_empty_string
76   BOOST_MPL_ASSERT((is_error<apply_wrap2<space, str_, start> >));
77 }
78 
79 
80