Last change
on this file since 33 was
29,
checked in by landauf, 16 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.4 KB
|
Line | |
---|
1 | // |
---|
2 | // Copyright (c) 2004 Joao Abecasis |
---|
3 | // |
---|
4 | // Use, modification and distribution is subject to the Boost Software |
---|
5 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | |
---|
9 | #include <boost/spirit/core.hpp> |
---|
10 | #include <boost/detail/lightweight_test.hpp> |
---|
11 | |
---|
12 | using namespace boost::spirit; |
---|
13 | |
---|
14 | void shortest_alternative_parser_test() |
---|
15 | { |
---|
16 | typedef |
---|
17 | shortest_alternative< |
---|
18 | shortest_alternative< |
---|
19 | shortest_alternative< |
---|
20 | strlit<>, |
---|
21 | strlit<> >, |
---|
22 | strlit<> >, |
---|
23 | strlit<> > |
---|
24 | parser_t; |
---|
25 | |
---|
26 | parser_t short_rule = |
---|
27 | shortest_d[ |
---|
28 | str_p("a") |
---|
29 | | str_p("aa") |
---|
30 | | str_p("aaa") |
---|
31 | | str_p("aaaa") |
---|
32 | ]; |
---|
33 | |
---|
34 | BOOST_TEST(parse("a", short_rule).full); |
---|
35 | BOOST_TEST(parse("aa", short_rule).length == 1); |
---|
36 | BOOST_TEST(parse("aaa", short_rule).length == 1); |
---|
37 | BOOST_TEST(parse("aaaa", short_rule).length == 1); |
---|
38 | |
---|
39 | short_rule = |
---|
40 | shortest_d[ |
---|
41 | str_p("d") |
---|
42 | | str_p("cd") |
---|
43 | | str_p("bcd") |
---|
44 | | str_p("abcd") |
---|
45 | ]; |
---|
46 | |
---|
47 | BOOST_TEST(parse("d", short_rule).full); |
---|
48 | BOOST_TEST(parse("cd", short_rule).full); |
---|
49 | BOOST_TEST(parse("bcd", short_rule).full); |
---|
50 | BOOST_TEST(parse("abcd", short_rule).full); |
---|
51 | } |
---|
52 | |
---|
53 | int |
---|
54 | main() |
---|
55 | { |
---|
56 | shortest_alternative_parser_test(); |
---|
57 | return boost::report_errors(); |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.