1 // Copyright 2008 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 #include "re2/regexp.h"
16 static PCRETest tests[] = {
17 // Most things should behave exactly.
23 { "a(()|())c", true },
26 { "a(b*|c*)d", true },
31 // Check that repeated empty strings do not.
39 // \v is the only character class that shouldn't.
44 // The handling of ^ in multi-line mode is different, as is
45 // the handling of $ in single-line mode. (Both involve
46 // boundary cases if the string ends with \n.)
52 { "(?-m)$", false }, // In PCRE, == \Z
59 TEST(MimicsPCRE, SimpleTests) {
60 for (int i = 0; i < arraysize(tests); i++) {
61 const PCRETest& t = tests[i];
62 for (int j = 0; j < 2; j++) {
63 Regexp::ParseFlags flags = Regexp::LikePerl;
65 flags = flags | Regexp::Latin1;
66 Regexp* re = Regexp::Parse(t.regexp, flags, NULL);
67 CHECK(re) << " " << t.regexp;
68 CHECK_EQ(t.should_match, re->MimicsPCRE())
69 << " " << t.regexp << " "
70 << (j==0 ? "latin1" : "utf");