mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-06 09:16:33 +02:00
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:
@ -132,7 +132,10 @@ namespace boost {
|
|||||||
// increment
|
// increment
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
m_Match=this->do_find(m_Match.end(),m_End);
|
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
|
// comparison
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <boost/algorithm/string/find.hpp>
|
#include <boost/algorithm/string/find.hpp>
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
|
||||||
// Include unit test framework
|
// Include unit test framework
|
||||||
#include <boost/test/included/test_exec_monitor.hpp>
|
#include <boost/test/included/test_exec_monitor.hpp>
|
||||||
@ -248,6 +249,20 @@ void find_test()
|
|||||||
ostringstream osstr;
|
ostringstream osstr;
|
||||||
osstr << find_first( str1, "abc" );
|
osstr << find_first( str1, "abc" );
|
||||||
BOOST_CHECK( osstr.str()=="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
|
// test main
|
||||||
|
Reference in New Issue
Block a user