]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (c) 2001-2010 Hartmut Kaiser |
2 | // | |
3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | // this file deliberately contains non-ascii characters | |
7 | // boostinspect:noascii | |
8 | ||
9 | #include <boost/config/warning_disable.hpp> | |
10 | #include <boost/detail/lightweight_test.hpp> | |
11 | ||
12 | #include <boost/spirit/include/karma_operator.hpp> | |
13 | #include <boost/spirit/include/karma_char.hpp> | |
14 | #include <boost/spirit/include/karma_auxiliary.hpp> | |
15 | #include <boost/spirit/include/karma_string.hpp> | |
16 | #include <boost/spirit/include/karma_numeric.hpp> | |
17 | #include <boost/spirit/include/karma_nonterminal.hpp> | |
18 | #include <boost/spirit/include/karma_action.hpp> | |
19 | #include <boost/spirit/include/karma_directive.hpp> | |
20 | #include <boost/spirit/include/phoenix_core.hpp> | |
21 | #include <boost/spirit/include/phoenix_operator.hpp> | |
22 | #include <boost/spirit/include/phoenix_statement.hpp> | |
23 | #include <boost/spirit/include/phoenix_fusion.hpp> | |
24 | ||
25 | #include "test.hpp" | |
26 | ||
27 | using namespace spirit_test; | |
28 | ||
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | int main() | |
31 | { | |
32 | using namespace boost; | |
33 | using namespace boost::spirit; | |
34 | using namespace boost::spirit::ascii; | |
35 | ||
36 | typedef spirit_test::output_iterator<char>::type outiter_type; | |
37 | ||
38 | { | |
39 | karma::rule<outiter_type, void(char, int, double)> start; | |
40 | fusion::vector<char, int, double> vec('a', 10, 12.4); | |
41 | ||
42 | start = char_[_1 = _r1] << int_[_1 = _r2] << double_[_1 = _r3]; | |
43 | BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); | |
44 | ||
45 | start = (char_ << int_ << double_)[_1 = _r1, _2 = _r2, _3 = _r3]; | |
46 | BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); | |
47 | ||
48 | karma::rule<outiter_type, void(char)> a; | |
49 | karma::rule<outiter_type, void(int)> b; | |
50 | karma::rule<outiter_type, void(double)> c; | |
51 | ||
52 | a = char_[_1 = _r1]; | |
53 | b = int_[_1 = _r1]; | |
54 | c = double_[_1 = _r1]; | |
55 | start = a(_r1) << b(_r2) << c(_r3); | |
56 | BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); | |
57 | } | |
58 | ||
59 | { | |
60 | karma::rule<outiter_type, space_type, void(char, int, double)> start; | |
61 | fusion::vector<char, int, double> vec('a', 10, 12.4); | |
62 | ||
63 | start = char_[_1 = _r1] << int_[_1 = _r2] << double_[_1 = _r3]; | |
64 | BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); | |
65 | ||
66 | start = (char_ << int_ << double_)[_1 = _r1, _2 = _r2, _3 = _r3]; | |
67 | BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); | |
68 | ||
69 | karma::rule<outiter_type, space_type, void(char)> a; | |
70 | karma::rule<outiter_type, space_type, void(int)> b; | |
71 | karma::rule<outiter_type, space_type, void(double)> c; | |
72 | ||
73 | a = char_[_1 = _r1]; | |
74 | b = int_[_1 = _r1]; | |
75 | c = double_[_1 = _r1]; | |
76 | start = a(_r1) << b(_r2) << c(_r3); | |
77 | BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); | |
78 | } | |
79 | ||
80 | // copy tests | |
81 | { | |
7c673cae FG |
82 | karma::rule<outiter_type> a, b, c, start; |
83 | ||
84 | a = 'a'; | |
85 | b = int_(10); | |
86 | c = double_(12.4); | |
87 | ||
88 | // The FF is the dynamic equivalent of start = a << b << c; | |
89 | start = a; | |
90 | start = start.copy() << b; | |
91 | start = start.copy() << c; | |
92 | start = start.copy(); | |
93 | ||
94 | BOOST_TEST(test("a1012.4", start)); | |
95 | } | |
96 | ||
97 | { | |
7c673cae FG |
98 | karma::rule<outiter_type, space_type> a, b, c, start; |
99 | ||
100 | a = 'a'; | |
101 | b = int_(10); | |
102 | c = double_(12.4); | |
103 | ||
104 | // The FF is the dynamic equivalent of start = a << b << c; | |
105 | start = a; | |
106 | start = start.copy() << b; | |
107 | start = start.copy() << c; | |
108 | start = start.copy(); | |
109 | ||
110 | BOOST_TEST(test_delimited("a 10 12.4 ", start, space)); | |
111 | } | |
112 | ||
113 | #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) | |
114 | #pragma setlocale("french") | |
115 | #endif | |
116 | { // specifying the encoding | |
117 | using karma::lower; | |
118 | using karma::upper; | |
119 | using karma::string; | |
120 | ||
121 | typedef boost::spirit::char_encoding::iso8859_1 iso8859_1; | |
122 | karma::rule<outiter_type, iso8859_1> r; | |
123 | ||
124 |