summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/test/qi/char2.cpp
blob: 72c1f5bad4a7e146a1787ec57082e922f109951f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*=============================================================================
    Copyright (c) 2001-2011 Joel de Guzman
    Copyright (c) 2001-2011 Hartmut Kaiser

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/qi_char.hpp>
#include <boost/spirit/include/qi_action.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>

#include <iostream>
#include "test.hpp"

int
main()
{
    using spirit_test::test;
    using spirit_test::test_attr;
    using spirit_test::print_info;

    {
        using boost::spirit::qi::lit;

        BOOST_TEST(test("x", lit('x')));
        BOOST_TEST(!test("x", lit('y')));

        BOOST_TEST(!test("x", ~lit('x')));
        BOOST_TEST(test(" ", ~lit('x')));
        BOOST_TEST(test("X", ~lit('x')));

        BOOST_TEST(test("x", ~~lit('x')));
        BOOST_TEST(!test(" ", ~~lit('x')));
        BOOST_TEST(!test("X", ~~lit('x')));
    }

    {
        using boost::spirit::qi::lit;
        using boost::spirit::qi::space;

        BOOST_TEST(test("   x", lit('x'), space));
        BOOST_TEST(!test("   x", lit('y'), space));
    }

    {
        using boost::spirit::qi::lit;

        BOOST_TEST(test(L"x", lit(L'x')));
        BOOST_TEST(!test(L"x", lit(L'y')));

        BOOST_TEST(!test(L"x", ~lit(L'x')));
        BOOST_TEST(test(L" ", ~lit(L'x')));
        BOOST_TEST(test(L"X", ~lit(L'x')));

        BOOST_TEST(test(L"x", ~~lit(L'x')));
        BOOST_TEST(!test(L" ", ~~lit(L'x')));
        BOOST_TEST(!test(L"X", ~~lit(L'x')));
    }

    {   // lazy chars
        using boost::spirit::qi::lit;

        using boost::phoenix::val;

        BOOST_TEST((test("x", lit(val('x')))));
    }

    return boost::report_errors();
}