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