Ticket #7784: OverlappingStringTest.cpp

File OverlappingStringTest.cpp, 624 bytes (added by cedstrom@…, 10 years ago)

Overlapping String Test Case

Line 
1#include <list>
2#include <boost/algorithm/string/finder.hpp>
3#include <boost/algorithm/string/split.hpp>
4#include <boost/foreach.hpp>
5
6using namespace std;
7using namespace boost;
8using boost::algorithm::find_all;
9
10int main(int argc, char* argv[])
11{
12 std::string haystack("AAAA");
13 std::string needle("AAA");
14
15 std::list<boost::iterator_range<std::string::iterator>> out;
16 boost::algorithm::find_all(out, haystack, needle);
17
18 cout << "matches=" << out.size() << endl;
19
20 BOOST_FOREACH(boost::iterator_range<std::string::iterator> it, out)
21 {
22 cout << (it.begin() - haystack.begin()) << ' ';
23 }
24
25 cout << endl;
26
27 return 0;
28}