]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | http://spirit.sourceforge.net/ | |
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 | =============================================================================*/ | |
7c673cae | 8 | #include <boost/spirit/include/qi_string.hpp> |
1e59de90 | 9 | |
7c673cae FG |
10 | #include <boost/spirit/include/qi_char.hpp> |
11 | #include <boost/spirit/include/qi_action.hpp> | |
1e59de90 TL |
12 | #include <boost/phoenix/core.hpp> |
13 | #include <boost/phoenix/operator.hpp> | |
7c673cae FG |
14 | |
15 | #include <iostream> | |
16 | #include "test.hpp" | |
17 | ||
18 | int | |
19 | main() | |
20 | { | |
21 | using spirit_test::test; | |
22 | using spirit_test::test_attr; | |
23 | using boost::spirit::qi::string; | |
24 | using boost::spirit::qi::_1; | |
25 | ||
26 | { | |
27 | BOOST_TEST((test("kimpo", "kimpo"))); | |
28 | BOOST_TEST((test("kimpo", string("kimpo")))); | |
29 | ||
30 | BOOST_TEST((test("x", string("x")))); | |
31 | BOOST_TEST((test(L"x", string(L"x")))); | |
32 | ||
33 | std::basic_string<char> s("kimpo"); | |
34 | std::basic_string<wchar_t> ws(L"kimpo"); | |
35 | BOOST_TEST((test("kimpo", s))); | |
36 | BOOST_TEST((test(L"kimpo", ws))); | |
37 | BOOST_TEST((test("kimpo", string(s)))); | |
38 | BOOST_TEST((test(L"kimpo", string(ws)))); | |
39 | } | |
40 | ||
41 | { | |
42 | BOOST_TEST((test(L"kimpo", L"kimpo"))); | |
43 | BOOST_TEST((test(L"kimpo", string(L"kimpo")))); | |
44 | BOOST_TEST((test(L"x", string(L"x")))); | |
45 | } | |
46 | ||
47 | { | |
48 | std::basic_string<char> s("kimpo"); | |
49 | BOOST_TEST((test("kimpo", string(s)))); | |
50 | ||
51 | std::basic_string<wchar_t> ws(L"kimpo"); | |
52 | BOOST_TEST((test(L"kimpo", string(ws)))); | |
53 | } | |
54 | ||
55 | { | |
56 | using namespace boost::spirit::ascii; | |
57 | BOOST_TEST((test(" kimpo", string("kimpo"), space))); | |
58 | BOOST_TEST((test(L" kimpo", string(L"kimpo"), space))); | |
59 | BOOST_TEST((test(" x", string("x"), space))); | |
60 | } | |
61 | ||
62 | { | |
63 | using namespace boost::spirit::ascii; | |
64 | BOOST_TEST((test(" kimpo", string("kimpo"), space))); | |
65 | BOOST_TEST((test(L" kimpo", string(L"kimpo"), space))); | |
66 | BOOST_TEST((test(" x", string("x"), space))); | |
67 | } | |
68 | ||
69 | { | |
70 | using namespace boost::spirit::ascii; | |
71 | std::string s; | |
72 | BOOST_TEST((test_attr("kimpo", string("kimpo"), s))); | |
73 | BOOST_TEST(s == "kimpo"); | |
74 | s.clear(); | |
75 | BOOST_TEST((test_attr(L"kimpo", string(L"kimpo"), s))); | |
76 | BOOST_TEST(s == "kimpo"); | |
77 | s.clear(); | |
78 | BOOST_TEST((test_attr("x", string("x"), s))); | |
79 | BOOST_TEST(s == "x"); | |
80 | } | |
81 | ||
82 | { // lazy string | |
83 | ||
84 | using namespace boost::spirit::ascii; | |
85 | namespace phx = boost::phoenix; | |
86 | ||
87 | BOOST_TEST((test("x", string(phx::val("x"))))); | |
88 | ||
89 | std::string str; // make sure lazy lits have an attribute | |
90 | BOOST_TEST(test("x", string(phx::val("x"))[phx::ref(str) = _1])); | |
91 | BOOST_TEST(str == "x"); | |
92 | } | |
93 | ||
94 | return boost::report_errors(); | |
95 | } |