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/spirit/include/qi_char.hpp> // not qi_lit.hpp!
9
10#include <boost/spirit/include/qi_action.hpp>
11#include <boost/phoenix/core.hpp>
12#include <boost/phoenix/operator.hpp>
13
14#include <iostream>
15#include "test.hpp"
16
17int
18main()
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
42 BOOST_TEST(test(" x", lit('x'), lit(' ')));
43 BOOST_TEST(!test(" x", lit('y'), lit(' ')));
44 }
45
46 {
47 using boost::spirit::qi::lit;
48
49 BOOST_TEST(test(L"x", lit(L'x')));
50 BOOST_TEST(!test(L"x", lit(L'y')));
51
52 BOOST_TEST(!test(L"x", ~lit(L'x')));
53 BOOST_TEST(test(L" ", ~lit(L'x')));
54 BOOST_TEST(test(L"X", ~lit(L'x')));
55
56 BOOST_TEST(test(L"x", ~~lit(L'x')));
57 BOOST_TEST(!test(L" ", ~~lit(L'x')));
58 BOOST_TEST(!test(L"X", ~~lit(L'x')));
59 }
60
61 { // lazy chars
62 using boost::spirit::qi::lit;
63
64 using boost::phoenix::val;
65
66 BOOST_TEST((test("x", lit(val('x')))));
67 }
68
69 return boost::report_errors();
70}
71

source code of boost/libs/spirit/test/qi/char2.cpp