Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/re2/re2/testing/required_prefix_test.cc

Issue 1516543002: Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2009 The RE2 Authors. All Rights Reserved. 1 // Copyright 2009 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "util/test.h" 5 #include "util/test.h"
6 #include "re2/regexp.h" 6 #include "re2/regexp.h"
7 7
8 namespace re2 { 8 namespace re2 {
9 9
10 struct PrefixTest { 10 struct PrefixTest {
(...skipping 10 matching lines...) Expand all
21 { "", false }, 21 { "", false },
22 { "(?m)^", false }, 22 { "(?m)^", false },
23 23
24 // If the regexp immediately goes into 24 // If the regexp immediately goes into
25 // something not a literal match, there's no required prefix. 25 // something not a literal match, there's no required prefix.
26 { "^(abc)", false }, 26 { "^(abc)", false },
27 { "^a*", false }, 27 { "^a*", false },
28 28
29 // Otherwise, it should work. 29 // Otherwise, it should work.
30 { "^abc$", true, "abc", false, "(?-m:$)" }, 30 { "^abc$", true, "abc", false, "(?-m:$)" },
31 { "^abc", "true", "abc", false, "" }, 31 { "^abc", true, "abc", false, "" },
32 { "^(?i)abc", true, "abc", true, "" }, 32 { "^(?i)abc", true, "abc", true, "" },
33 { "^abcd*", true, "abc", false, "d*" }, 33 { "^abcd*", true, "abc", false, "d*" },
34 { "^[Aa][Bb]cd*", true, "ab", true, "cd*" }, 34 { "^[Aa][Bb]cd*", true, "ab", true, "cd*" },
35 { "^ab[Cc]d*", true, "ab", false, "[Cc]d*" }, 35 { "^ab[Cc]d*", true, "ab", false, "[Cc]d*" },
36 { "^☺abc", true, "☺abc", false, "" }, 36 { "^☺abc", true, "☺abc", false, "" },
37 }; 37 };
38 38
39 TEST(RequiredPrefix, SimpleTests) { 39 TEST(RequiredPrefix, SimpleTests) {
40 for (int i = 0; i < arraysize(tests); i++) { 40 for (int i = 0; i < arraysize(tests); i++) {
41 const PrefixTest& t = tests[i]; 41 const PrefixTest& t = tests[i];
(...skipping 16 matching lines...) Expand all
58 CHECK_EQ(s->ToString(), string(t.suffix)) 58 CHECK_EQ(s->ToString(), string(t.suffix))
59 << " " << t.regexp << " " << (j==0 ? "latin1" : "utf"); 59 << " " << t.regexp << " " << (j==0 ? "latin1" : "utf");
60 s->Decref(); 60 s->Decref();
61 } 61 }
62 re->Decref(); 62 re->Decref();
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 } // namespace re2 67 } // namespace re2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698