summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/test/qi/regression_clear.cpp
blob: 3c7fe77d0a028a483b2e28a9f742eae1a412eeeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//  Copyright (c) 2010 Daniel James
//  Copyright (c) 2001-2010 Hartmut Kaiser
// 
//  Distributed under the Boost Software License, Version 1.0. (See accompanying 
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/config/warning_disable.hpp>
#include <boost/detail/lightweight_test.hpp>

#include <boost/spirit/include/qi.hpp>
#include <vector>

int main() 
{
    typedef char const* Iterator;
    namespace qi = boost::spirit::qi;

    qi::rule<Iterator, std::vector<boost::iterator_range<Iterator> >()> list;
    list = *qi::raw[qi::char_]; // This fails to compile
    
    char const* test = "abcdef";
    unsigned test_length = 6;
    char const* test_begin = test;
    char const* test_end = test + test_length;
    std::vector<boost::iterator_range<Iterator> > result;
    bool r = qi::parse(test_begin, test_end, list, result);
    
    BOOST_TEST(r);
    BOOST_TEST(test_begin == test_end);
    BOOST_TEST(result.size() == test_length);

    for(unsigned i = 0; i < test_length; ++i) {
        BOOST_TEST(result[i].begin() == test + i);
        BOOST_TEST(result[i].end() == test + i + 1);
    }

    return boost::report_errors();
}