| 1 | // Copyright (c) 2010 Daniel James |
|---|---|
| 2 | // Copyright (c) 2001-2010 Hartmut Kaiser |
| 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.hpp> |
| 8 | |
| 9 | #include <boost/core/lightweight_test.hpp> |
| 10 | #include <vector> |
| 11 | |
| 12 | int main() |
| 13 | { |
| 14 | typedef char const* Iterator; |
| 15 | namespace qi = boost::spirit::qi; |
| 16 | |
| 17 | qi::rule<Iterator, std::vector<boost::iterator_range<Iterator> >()> list; |
| 18 | list = *qi::raw[qi::char_]; // This fails to compile |
| 19 | |
| 20 | char const* test = "abcdef"; |
| 21 | unsigned test_length = 6; |
| 22 | char const* test_begin = test; |
| 23 | char const* test_end = test + test_length; |
| 24 | std::vector<boost::iterator_range<Iterator> > result; |
| 25 | bool r = qi::parse(first&: test_begin, last: test_end, expr: list, attr&: result); |
| 26 | |
| 27 | BOOST_TEST(r); |
| 28 | BOOST_TEST(test_begin == test_end); |
| 29 | BOOST_TEST(result.size() == test_length); |
| 30 | |
| 31 | for(unsigned i = 0; i < test_length; ++i) { |
| 32 | BOOST_TEST(result[i].begin() == test + i); |
| 33 | BOOST_TEST(result[i].end() == test + i + 1); |
| 34 | } |
| 35 | |
| 36 | return boost::report_errors(); |
| 37 | } |
| 38 |
