diff --git a/include/boost/algorithm/string/find_iterator.hpp b/include/boost/algorithm/string/find_iterator.hpp index b72ba7c..07a909e 100644 --- a/include/boost/algorithm/string/find_iterator.hpp +++ b/include/boost/algorithm/string/find_iterator.hpp @@ -132,7 +132,10 @@ namespace boost { // 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 diff --git a/string/test/find_test.cpp b/string/test/find_test.cpp index 67d3759..a93c878 100644 --- a/string/test/find_test.cpp +++ b/string/test/find_test.cpp @@ -9,6 +9,7 @@ #include #include +#include // Include unit test framework #include @@ -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 > 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