aboutsummaryrefslogtreecommitdiff
path: root/re2/testing/re2_test.cc
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2014-01-09 22:31:48 -0500
committerRuss Cox <rsc@swtch.com>2014-01-09 22:31:48 -0500
commit33d2a42e2501fa294c41cec1f0f3d8d1a7e9c2e8 (patch)
treee373854c277cf5fba77ae19eba0f472fa7ba54c9 /re2/testing/re2_test.cc
parent0a4ddd94dbfced0c3ebeb3ac44f9b14a02f5da01 (diff)
downloadregex-re2-33d2a42e2501fa294c41cec1f0f3d8d1a7e9c2e8.tar.gz
re2: fix bitstate for empty char classes
Fixes issue 52. R=rsc CC=re2-dev https://codereview.appspot.com/50370043
Diffstat (limited to 're2/testing/re2_test.cc')
-rw-r--r--re2/testing/re2_test.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc
index 0c8896f..e2f9775 100644
--- a/re2/testing/re2_test.cc
+++ b/re2/testing/re2_test.cc
@@ -483,6 +483,21 @@ TEST(EmptyCharset, Fuzz) {
CHECK(!RE2(empties[i]).Match("abc", 0, 3, RE2::UNANCHORED, NULL, 0));
}
+// Bitstate assumes that kInstFail instructions in
+// alternations or capture groups have been "compiled away".
+TEST(EmptyCharset, BitstateAssumptions) {
+ // Captures trigger use of Bitstate.
+ static const char *nop_empties[] = {
+ "((((()))))" "[^\\S\\s]?",
+ "((((()))))" "([^\\S\\s])?",
+ "((((()))))" "([^\\S\\s]|[^\\S\\s])?",
+ "((((()))))" "(([^\\S\\s]|[^\\S\\s])|)"
+ };
+ StringPiece group[6];
+ for (int i = 0; i < arraysize(nop_empties); i++)
+ CHECK(RE2(nop_empties[i]).Match("", 0, 0, RE2::UNANCHORED, group, 6));
+}
+
// Test that named groups work correctly.
TEST(Capture, NamedGroups) {
{