]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/test/karma/regression_unicode_char.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / spirit / test / karma / regression_unicode_char.cpp
CommitLineData
7c673cae
FG
1// Copyright (c) 2012 David Bailey
2// Copyright (c) 2001-2012 Hartmut Kaiser
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
7c673cae
FG
7#ifndef BOOST_SPIRIT_UNICODE
8#define BOOST_SPIRIT_UNICODE
9#endif
10
11#include <boost/spirit/home/karma/nonterminal/grammar.hpp>
12#include <boost/spirit/home/karma/nonterminal/rule.hpp>
13#include <boost/spirit/home/karma/char.hpp>
14
15#include "test.hpp"
16
17using namespace spirit_test;
18
19///////////////////////////////////////////////////////////////////////////////
20template <typename OutputIterator>
21struct unicode_char_grammar_
22 : public boost::spirit::karma::grammar<
23 OutputIterator, boost::spirit::char_encoding::unicode::char_type()>
24{
25 unicode_char_grammar_() : unicode_char_grammar_::base_type(thechar)
26 {
27 using boost::spirit::karma::unicode::char_;
28 thechar = char_;
29 }
30
31 boost::spirit::karma::rule<
32 OutputIterator, boost::spirit::char_encoding::unicode::char_type()
33 > thechar;
34};
35
36int
37main()
38{
39 using namespace boost::spirit;
40
41 {
42 typedef std::basic_string<char_encoding::unicode::char_type> unicode_string;
43 typedef std::back_insert_iterator<unicode_string> unicode_back_insert_iterator_type;
44
45 using namespace boost::spirit::unicode;
46
47 BOOST_TEST(test("x", char_, 'x'));
48 BOOST_TEST(test(L"x", char_, L'x'));
49
50 char_encoding::unicode::char_type unicodeCharacter = 0x00000078u;
51 std::basic_string<char_encoding::unicode::char_type> expected;
52 expected.push_back(unicodeCharacter);
53
54 unicode_char_grammar_<unicode_back_insert_iterator_type> unichar;
55
56 BOOST_TEST(test(expected, unichar, unicodeCharacter));
57 }
58
59 return boost::report_errors();
60}