Update of /cvsroot/boost/boost/libs/xpressive/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13047/libs/xpressive/test

Modified Files:
        regress.ipp 
Log Message:
regex_token_iterator's value_type is sub_match<>::string_type, not 
basic_string<>, add regex_token_iterator test

Index: regress.ipp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/test/regress.ipp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- regress.ipp 18 Mar 2007 18:30:50 -0000      1.6
+++ regress.ipp 29 May 2007 03:06:10 -0000      1.7
@@ -264,21 +264,47 @@
 
         if(0 == (test.match_flags & regex_constants::format_first_only))
         {
-            // global search, use regex_iterator
-            std::vector<sub_match<iterator> > br;
-            regex_iterator<iterator> begin(test.str.begin(), test.str.end(), 
rx, test.match_flags), end;
-            for(; begin != end; ++begin)
             {
-                match_results<iterator> const &what = *begin;
-                br.insert(br.end(), what.begin(), what.end());
-            }
+                // global search, use regex_iterator
+                std::vector<sub_match<iterator> > br;
+                regex_iterator<iterator> begin(test.str.begin(), 
test.str.end(), rx, test.match_flags), end;
+                for(; begin != end; ++begin)
+                {
+                    match_results<iterator> const &what = *begin;
+                    br.insert(br.end(), what.begin(), what.end());
+                }
 
-            // match succeeded: was it expected to succeed?
-            BOOST_XPR_CHECK(br.size() == test.br.size());
+                // match succeeded: was it expected to succeed?
+                BOOST_XPR_CHECK(br.size() == test.br.size());
+
+                for(std::size_t i = 0; i < br.size() && i < test.br.size(); 
++i)
+                {
+                    BOOST_XPR_CHECK(!br[i].matched && test.br[i] == empty || 
test.br[i] == br[i].str());
+                }
+            }
 
-            for(std::size_t i = 0; i < br.size() && i < test.br.size(); ++i)
             {
-                BOOST_XPR_CHECK(!br[i].matched && test.br[i] == empty || 
test.br[i] == br[i].str());
+                // global search, use regex_token_iterator
+                std::vector<typename sub_match<iterator>::string_type> br2;
+                std::vector<int> subs(rx.mark_count() + 1, 0);
+                // regex_token_iterator will extract all sub_matches, in order:
+                for(std::size_t i = 0; i < subs.size(); ++i)
+                {
+                    subs[i] = static_cast<int>(i);
+                }
+                regex_token_iterator<iterator> begin2(test.str.begin(), 
test.str.end(), rx, subs, test.match_flags), end2;
+                for(; begin2 != end2; ++begin2)
+                {
+                    br2.push_back(*begin2);
+                }
+
+                // match succeeded: was it expected to succeed?
+                BOOST_XPR_CHECK(br2.size() == test.br.size());
+
+                for(std::size_t i = 0; i < br2.size() && i < test.br.size(); 
++i)
+                {
+                    BOOST_XPR_CHECK(test.br[i] == br2[i]);
+                }
             }
         }
         else


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to