1 | /*============================================================================= |
---|---|
2 | Copyright (c) 2001-2010 Joel de Guzman |
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 | =============================================================================*/ |
7 | #include <boost/spirit/include/qi_hold.hpp> |
8 | |
9 | #include <boost/spirit/include/qi_char.hpp> |
10 | #include <boost/spirit/include/qi_int.hpp> |
11 | #include <boost/spirit/include/qi_operator.hpp> |
12 | |
13 | #include <iostream> |
14 | #include <vector> |
15 | #include "test.hpp" |
16 | |
17 | int |
18 | main() |
19 | { |
20 | using spirit_test::test; |
21 | using spirit_test::test_attr; |
22 | using boost::spirit::qi::hold; |
23 | using boost::spirit::qi::int_; |
24 | using boost::spirit::ascii::alpha; |
25 | |
26 | { |
27 | std::vector<int> vec; |
28 | BOOST_TEST(!test_attr("1$", hold[int_ >> ';'], vec)); |
29 | BOOST_TEST(vec.size() == 0); |
30 | BOOST_TEST(test_attr("1;", hold[int_ >> ';'], vec)); |
31 | BOOST_TEST(vec.size() == 1); |
32 | BOOST_TEST(vec[0] == 1); |
33 | } |
34 | |
35 | { |
36 | std::string attr; |
37 | BOOST_TEST( |
38 | test_attr( |
39 | "abc;", |
40 | hold[alpha >> ';'] | (+alpha >> ';'), |
41 | attr)); |
42 | BOOST_TEST(attr == "abc"); |
43 | } |
44 | |
45 | return boost::report_errors(); |
46 | } |
47 |