1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2001-2011 Hartmut Kaiser
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/spirit/include/qi_char.hpp>
10 #include <boost/spirit/include/qi_action.hpp>
11 #include <boost/spirit/include/phoenix_core.hpp>
12 #include <boost/spirit/include/phoenix_operator.hpp>
13 
14 #include <iostream>
15 #include "test.hpp"
16 
17 int
main()18 main()
19 {
20     using spirit_test::test;
21     using spirit_test::test_attr;
22     using spirit_test::print_info;
23 
24     {
25         using boost::spirit::qi::lit;
26 
27         BOOST_TEST(test("x", lit('x')));
28         BOOST_TEST(!test("x", lit('y')));
29 
30         BOOST_TEST(!test("x", ~lit('x')));
31         BOOST_TEST(test(" ", ~lit('x')));
32         BOOST_TEST(test("X", ~lit('x')));
33 
34         BOOST_TEST(test("x", ~~lit('x')));
35         BOOST_TEST(!test(" ", ~~lit('x')));
36         BOOST_TEST(!test("X", ~~lit('x')));
37     }
38 
39     {
40         using boost::spirit::qi::lit;
41         using boost::spirit::qi::space;
42 
43         BOOST_TEST(test("   x", lit('x'), space));
44         BOOST_TEST(!test("   x", lit('y'), space));
45     }
46 
47     {
48         using boost::spirit::qi::lit;
49 
50         BOOST_TEST(test(L"x", lit(L'x')));
51         BOOST_TEST(!test(L"x", lit(L'y')));
52 
53         BOOST_TEST(!test(L"x", ~lit(L'x')));
54         BOOST_TEST(test(L" ", ~lit(L'x')));
55         BOOST_TEST(test(L"X", ~lit(L'x')));
56 
57         BOOST_TEST(test(L"x", ~~lit(L'x')));
58         BOOST_TEST(!test(L" ", ~~lit(L'x')));
59         BOOST_TEST(!test(L"X", ~~lit(L'x')));
60     }
61 
62     {   // lazy chars
63         using boost::spirit::qi::lit;
64 
65         using boost::phoenix::val;
66 
67         BOOST_TEST((test("x", lit(val('x')))));
68     }
69 
70     return boost::report_errors();
71 }
72