[PATCH] [libcxx] Fix match_results for alternatives

Agustín Bergé kaballo86 at hotmail.com
Fri Jan 23 10:52:26 PST 2015


In http://reviews.llvm.org/D7111#112810, @mclow.lists wrote:

> The fix looks reasonable, it fixes the OP's problem, and the new test fails w/o the fix.
>
> However, the change to <regex> is in two places, and I don't see how this test exercises both code paths.


Good point, I'll parametrize the test and invoke it for both ECMAScript and extended POSIX.


================
Comment at: test/std/re/re.results/re.results.acc/index.pass.cpp:25
@@ -25,2 +24,3 @@
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi|(z)")));
 
     assert(m[0].first == s+2);
----------------
mclow.lists wrote:
> How about `assert(m.size() == 6)` here? - or `>5` since we're checking elements 0..5
`assert(m.size() == 4)` actually, the main match plus three subexpressions. Any out of range access shall return an unmatched result, and the original test was exercising that.

================
Comment at: test/std/re/re.results/re.results.acc/index.pass.cpp:48
@@ -45,1 +47,3 @@
+    assert(m[5].second == s+11);
+    assert(m[4].matched == false);
 }
----------------
mclow.lists wrote:
> Should this be `m[5]` ?
Indeed, good catch.

http://reviews.llvm.org/D7111

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list