summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/test/qi/encoding.cpp
blob: 54c34e859aa5e61ec0ef621738d1157b6a3c3167 (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
/*=============================================================================
    Copyright (c) 2001-2011 Joel de Guzman
    http://spirit.sourceforge.net/

    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_string.hpp>
#include <boost/spirit/include/qi_directive.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 boost::spirit::qi::lit;
    using boost::spirit::qi::no_case;
    using boost::spirit::qi::char_;
    using boost::spirit::qi::encoding;
    namespace char_encoding = boost::spirit::char_encoding;

    encoding<char_encoding::iso8859_1> iso8859_1;

    { // test extended ASCII characters
        BOOST_TEST(test("\xC1", iso8859_1[no_case['\xE1']]));
        BOOST_TEST(test("\xC1", iso8859_1[no_case[char_('\xE1')]]));

        BOOST_TEST(test("\xC9", iso8859_1[no_case[char_("\xE5-\xEF")]]));
        BOOST_TEST(!test("\xFF", iso8859_1[no_case[char_("\xE5-\xEF")]]));

        BOOST_TEST(test("\xC1\xE1", iso8859_1[no_case["\xE1\xC1"]]));
        BOOST_TEST(test("\xC1\xE1", iso8859_1[no_case[lit("\xE1\xC1")]]));
    }

    return boost::report_errors();
}