Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59930 - in trunk/libs/spirit/test: . qi
From: hartmut.kaiser_at_[hidden]
Date: 2010-02-25 20:13:29


Author: hkaiser
Date: 2010-02-25 20:13:28 EST (Thu, 25 Feb 2010)
New Revision: 59930
URL: http://svn.boost.org/trac/boost/changeset/59930

Log:
Spirit: fixed #3815 (Clearing an iterator range), added test
Added:
   trunk/libs/spirit/test/qi/clear_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/spirit/test/Jamfile | 3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2010-02-25 20:13:28 EST (Thu, 25 Feb 2010)
@@ -144,6 +144,9 @@
     [ compile support/multi_pass_regression001.cpp : : support_multi_pass_regression001 ]
     [ compile support/multi_pass_regression002.cpp : : support_multi_pass_regression002 ]
     
+
+ # regression tests
+ [ run qi/clear_test.cpp : : : : ]
     ;
 
 }

Added: trunk/libs/spirit/test/qi/clear_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/clear_test.cpp 2010-02-25 20:13:28 EST (Thu, 25 Feb 2010)
@@ -0,0 +1,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";
+ int 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(int 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();
+}
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk