• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2010 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/include/qi_operator.hpp>
9 #include <boost/spirit/include/qi_char.hpp>
10 #include <boost/spirit/include/qi_string.hpp>
11 #include <boost/spirit/include/qi_numeric.hpp>
12 #include <boost/spirit/include/qi_directive.hpp>
13 #include <boost/spirit/include/qi_action.hpp>
14 #include <boost/spirit/include/support_argument.hpp>
15 #include <boost/spirit/include/phoenix_core.hpp>
16 #include <boost/spirit/include/phoenix_operator.hpp>
17 
18 #include <string>
19 #include <iostream>
20 #include "test.hpp"
21 
22 int
main()23 main()
24 {
25     using namespace boost::spirit::ascii;
26     using boost::spirit::lit;
27     using spirit_test::test;
28 
29     {
30         BOOST_TEST(test("b", char_ - 'a'));
31         BOOST_TEST(!test("a", char_ - 'a'));
32         BOOST_TEST(test("/* abcdefghijk */", "/*" >> *(char_ - "*/") >> "*/"));
33     }
34 
35     {
36         BOOST_TEST(test("b", char_ - no_case['a']));
37         BOOST_TEST(!test("a", char_ - no_case['a']));
38         BOOST_TEST(!test("A", char_ - no_case['a']));
39 
40         BOOST_TEST(test("b", no_case[lower - 'a']));
41         BOOST_TEST(test("B", no_case[lower - 'a']));
42         BOOST_TEST(!test("a", no_case[lower - 'a']));
43         BOOST_TEST(!test("A", no_case[lower - 'a']));
44     }
45 
46     {
47         // $$$ See difference.hpp why these tests are not done anymore. $$$
48 
49         // BOOST_TEST(test("switcher", lit("switcher") - "switch"));
50         // BOOST_TEST(test("    switcher    ", lit("switcher") - "switch", space));
51 
52         BOOST_TEST(!test("switch", lit("switch") - "switch"));
53     }
54 
55     {
56         using boost::spirit::_1;
57         namespace phx = boost::phoenix;
58 
59         std::string s;
60 
61         BOOST_TEST(test(
62             "/*abcdefghijk*/"
63           , "/*" >> *(char_ - "*/")[phx::ref(s) += _1] >> "*/"
64         ));
65         BOOST_TEST(s == "abcdefghijk");
66         s.clear();
67 
68         BOOST_TEST(test(
69             "    /*abcdefghijk*/"
70           , "/*" >> *(char_ - "*/")[phx::ref(s) += _1] >> "*/"
71           , space
72         ));
73         BOOST_TEST(s == "abcdefghijk");
74     }
75 
76     return boost::report_errors();
77 }
78 
79