Fixed bug in boost::algorithm::find_all with overlapping results; thanks to cedstrom for the report and the patch; Refs #7784

[SVN r82117]
This commit is contained in:
Marshall Clow
2012-12-20 15:52:59 +00:00
parent 54d2649b8c
commit d6d75c9a31
2 changed files with 19 additions and 1 deletions

View File

@ -132,7 +132,10 @@ namespace boost {
// increment
void increment()
{
if(m_Match.begin() == m_Match.end())
m_Match=this->do_find(m_Match.end(),m_End);
else
m_Match=this->do_find(m_Match.begin()+1,m_End);
}
// comparison

View File

@ -9,6 +9,7 @@
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
// Include unit test framework
#include <boost/test/included/test_exec_monitor.hpp>
@ -248,6 +249,20 @@ void find_test()
ostringstream osstr;
osstr << find_first( str1, "abc" );
BOOST_CHECK( osstr.str()=="abc" );
// Empty string test
BOOST_CHECKPOINT( "overlapping" );
std::string overlap_target("aaaa");
std::vector<boost::iterator_range<std::string::iterator> > overlap_results;
boost::algorithm::find_all(overlap_results, overlap_target, string("aaa"));
BOOST_CHECK( overlap_results.size() == 2 );
std::string overlap_target2("aaaabbbbaaaa");
boost::algorithm::find_all(overlap_results, overlap_target2, string("bb"));
BOOST_CHECK( overlap_results.size() == 3 );
boost::algorithm::find_all(overlap_results, overlap_target2, string("aa"));
BOOST_CHECK( overlap_results.size() == 6 );
}
// test main