8 #include "util/logging.h"
10 #include "re2/regexp.h"
37 {
"^abc$",
true,
"abc",
false,
"(?-m:$)" },
38 {
"^abc",
true,
"abc",
false,
"" },
39 {
"^(?i)abc",
true,
"abc",
true,
"" },
40 {
"^abcd*",
true,
"abc",
false,
"d*" },
41 {
"^[Aa][Bb]cd*",
true,
"ab",
true,
"cd*" },
42 {
"^ab[Cc]d*",
true,
"ab",
false,
"[Cc]d*" },
43 {
"^☺abc",
true,
"☺abc",
false,
"" },
46 TEST(RequiredPrefix, SimpleTests) {
48 const PrefixTest& t =
tests[
i];
49 for (
size_t j = 0; j < 2; j++) {
59 ASSERT_EQ(t.return_value, re->RequiredPrefix(&p, &f, &s))
60 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8")
64 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8");
66 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8");
68 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8");
92 {
"(ab?)def",
true,
"a",
false },
93 {
"(abc?)def",
true,
"ab",
false },
94 {
"(()a)def",
false },
95 {
"((a)b)def",
true,
"a",
false },
96 {
"((ab)c)def",
true,
"ab",
false },
99 {
"abc$",
true,
"abc",
false },
100 {
"abc",
true,
"abc",
false },
101 {
"(?i)abc",
true,
"abc",
true },
102 {
"abcd*",
true,
"abc",
false },
103 {
"[Aa][Bb]cd*",
true,
"ab",
true },
104 {
"ab[Cc]d*",
true,
"ab",
false },
105 {
"☺abc",
true,
"☺abc",
false },
108 TEST(RequiredPrefixForAccel, SimpleTests) {
111 for (
size_t j = 0; j < 2; j++) {
121 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8")
122 <<
" " << re->
Dump();
123 if (t.return_value) {
125 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8");
127 <<
" " << t.regexp <<
" " << (j == 0 ?
"latin1" :
"utf8");
134 TEST(RequiredPrefixForAccel, CaseFoldingForKAndS) {
173 TEST(PrefixAccel, SimpleTests) {
181 for (
int j = 0; j < 100; j++) {
183 const char* p =
reinterpret_cast<const char*
>(
186 text.append(
"aababc");
187 for (
int k = 0;
k < 100;
k++) {
189 p =
reinterpret_cast<const char*
>(