1 /*=============================================================================
2     Copyright (c) 2001-2015 Joel de Guzman
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/spirit/home/x3.hpp>
9 
10 #include <iostream>
11 #include "test.hpp"
12 
13 int
main()14 main()
15 {
16     using spirit_test::test;
17     using boost::spirit::x3::ascii::space;
18     using boost::spirit::x3::ascii::space_type;
19     using boost::spirit::x3::ascii::digit;
20     using boost::spirit::x3::lexeme;
21     using boost::spirit::x3::rule;
22 
23     {
24         BOOST_TEST((test(" 1 2 3 4 5", +digit, space)));
25         BOOST_TEST((!test(" 1 2 3 4 5", lexeme[+digit], space)));
26         BOOST_TEST((test(" 12345", lexeme[+digit], space)));
27         BOOST_TEST((test(" 12345  ", lexeme[+digit], space, false)));
28 
29         // lexeme collapsing
30         BOOST_TEST((!test(" 1 2 3 4 5", lexeme[lexeme[+digit]], space)));
31         BOOST_TEST((test(" 12345", lexeme[lexeme[+digit]], space)));
32         BOOST_TEST((test(" 12345  ", lexeme[lexeme[+digit]], space, false)));
33 
34         auto r = +digit;
35         auto rr = lexeme[r];
36 
37         BOOST_TEST((!test(" 1 2 3 4 5", rr, space)));
38         BOOST_TEST((test(" 12345", rr, space)));
39     }
40 
41     return boost::report_errors();
42 }
43