]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | /*============================================================================= |
1e59de90 | 2 | Copyright (c) 2003-2003 Vaclav Vesely |
7c673cae FG |
3 | http://spirit.sourceforge.net/ |
4 | ||
5 | Use, modification and distribution is subject to the Boost Software | |
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | http://www.boost.org/LICENSE_1_0.txt) | |
8 | =============================================================================*/ | |
9 | #include <boost/spirit/include/classic_core.hpp> | |
10 | #include <boost/spirit/include/classic_confix.hpp> | |
1e59de90 TL |
11 | |
12 | #include <boost/core/lightweight_test.hpp> | |
7c673cae FG |
13 | |
14 | using namespace boost; | |
15 | using namespace BOOST_SPIRIT_CLASSIC_NS; | |
16 | ||
17 | typedef | |
18 | scanner<char const*, scanner_policies<skipper_iteration_policy<> > > | |
19 | scanner_t; | |
20 | ||
21 | typedef | |
22 | rule<scanner_t> | |
23 | rule_t; | |
24 | ||
25 | void comment_nest_p_test() | |
26 | { | |
27 | rule_t r = comment_nest_p('{', '}'); | |
28 | ||
29 | { | |
30 | parse_info<> info = parse("{a{b}c{d}e}", r, space_p); | |
31 | BOOST_TEST(info.full); | |
32 | } | |
33 | ||
34 | { | |
35 | parse_info<> info = parse("{a{b}c{d}e}x", r, space_p); | |
36 | BOOST_TEST(info.hit); | |
37 | BOOST_TEST(info.length == 11); | |
38 | } | |
39 | ||
40 | { | |
41 | char const* str = "x{a{b}c{d}e}"; | |
42 | parse_info<> info = parse(str, r, space_p); | |
43 | BOOST_TEST(!info.hit); | |
44 | BOOST_TEST(info.stop == str); | |
45 | } | |
46 | ||
47 | { | |
48 | char const* str = "{a{b}c{d}e"; | |
49 | parse_info<> info = parse(str, r, space_p); | |
50 | BOOST_TEST(!info.hit); | |
51 | BOOST_TEST(info.stop == (str + 10)); | |
52 | } | |
53 | } | |
54 | ||
55 | int | |
56 | main() | |
57 | { | |
58 | comment_nest_p_test(); | |
59 | return boost::report_errors(); | |
60 | } | |
61 |