22 ASSERT_TRUE(re.IsValid());
24 EXPECT_TRUE(rs.Match(
"a"));
25 EXPECT_FALSE(rs.Match(
""));
26 EXPECT_FALSE(rs.Match(
"b"));
31 ASSERT_TRUE(re.IsValid());
33 EXPECT_TRUE(rs.Match(
"abc"));
34 EXPECT_FALSE(rs.Match(
""));
35 EXPECT_FALSE(rs.Match(
"a"));
36 EXPECT_FALSE(rs.Match(
"b"));
37 EXPECT_FALSE(rs.Match(
"ab"));
38 EXPECT_FALSE(rs.Match(
"abcd"));
42 Regex re(
"abab|abbb");
43 ASSERT_TRUE(re.IsValid());
45 EXPECT_TRUE(rs.Match(
"abab"));
46 EXPECT_TRUE(rs.Match(
"abbb"));
47 EXPECT_FALSE(rs.Match(
""));
48 EXPECT_FALSE(rs.Match(
"ab"));
49 EXPECT_FALSE(rs.Match(
"ababa"));
50 EXPECT_FALSE(rs.Match(
"abb"));
51 EXPECT_FALSE(rs.Match(
"abbbb"));
56 ASSERT_TRUE(re.IsValid());
58 EXPECT_TRUE(rs.Match(
"a"));
59 EXPECT_TRUE(rs.Match(
"b"));
60 EXPECT_TRUE(rs.Match(
"c"));
61 EXPECT_FALSE(rs.Match(
""));
62 EXPECT_FALSE(rs.Match(
"aa"));
63 EXPECT_FALSE(rs.Match(
"ab"));
68 ASSERT_TRUE(re.IsValid());
70 EXPECT_TRUE(rs.Match(
"abc"));
71 EXPECT_FALSE(rs.Match(
""));
72 EXPECT_FALSE(rs.Match(
"a"));
73 EXPECT_FALSE(rs.Match(
"b"));
74 EXPECT_FALSE(rs.Match(
"ab"));
75 EXPECT_FALSE(rs.Match(
"abcd"));
80 ASSERT_TRUE(re.IsValid());
82 EXPECT_TRUE(rs.Match(
"abc"));
83 EXPECT_FALSE(rs.Match(
""));
84 EXPECT_FALSE(rs.Match(
"a"));
85 EXPECT_FALSE(rs.Match(
"b"));
86 EXPECT_FALSE(rs.Match(
"ab"));
87 EXPECT_FALSE(rs.Match(
"abcd"));
91 Regex re(
"(a|b)(c|d)");
92 ASSERT_TRUE(re.IsValid());
94 EXPECT_TRUE(rs.Match(
"ac"));
95 EXPECT_TRUE(rs.Match(
"ad"));
96 EXPECT_TRUE(rs.Match(
"bc"));
97 EXPECT_TRUE(rs.Match(
"bd"));
98 EXPECT_FALSE(rs.Match(
""));
99 EXPECT_FALSE(rs.Match(
"ab"));
100 EXPECT_FALSE(rs.Match(
"cd"));
105 ASSERT_TRUE(re.IsValid());
107 EXPECT_TRUE(rs.Match(
""));
108 EXPECT_TRUE(rs.Match(
"a"));
109 EXPECT_FALSE(rs.Match(
"aa"));
114 ASSERT_TRUE(re.IsValid());
116 EXPECT_TRUE(rs.Match(
"b"));
117 EXPECT_TRUE(rs.Match(
"ab"));
118 EXPECT_FALSE(rs.Match(
"a"));
119 EXPECT_FALSE(rs.Match(
"aa"));
120 EXPECT_FALSE(rs.Match(
"bb"));
121 EXPECT_FALSE(rs.Match(
"ba"));
126 ASSERT_TRUE(re.IsValid());
128 EXPECT_TRUE(rs.Match(
"a"));
129 EXPECT_TRUE(rs.Match(
"ab"));
130 EXPECT_FALSE(rs.Match(
"b"));
131 EXPECT_FALSE(rs.Match(
"aa"));
132 EXPECT_FALSE(rs.Match(
"bb"));
133 EXPECT_FALSE(rs.Match(
"ba"));
138 ASSERT_TRUE(re.IsValid());
140 EXPECT_TRUE(rs.Match(
""));
141 EXPECT_TRUE(rs.Match(
"a"));
142 EXPECT_TRUE(rs.Match(
"b"));
143 EXPECT_TRUE(rs.Match(
"ab"));
144 EXPECT_FALSE(rs.Match(
"aa"));
145 EXPECT_FALSE(rs.Match(
"bb"));
146 EXPECT_FALSE(rs.Match(
"ba"));
147 EXPECT_FALSE(rs.Match(
"abc"));
152 ASSERT_TRUE(re.IsValid());
154 EXPECT_TRUE(rs.Match(
"ab"));
155 EXPECT_TRUE(rs.Match(
"aabb"));
156 EXPECT_FALSE(rs.Match(
"aab"));
157 EXPECT_FALSE(rs.Match(
"abb"));
162 ASSERT_TRUE(re.IsValid());
164 EXPECT_TRUE(rs.Match(
""));
165 EXPECT_TRUE(rs.Match(
"a"));
166 EXPECT_TRUE(rs.Match(
"aa"));
167 EXPECT_FALSE(rs.Match(
"b"));
168 EXPECT_FALSE(rs.Match(
"ab"));
173 ASSERT_TRUE(re.IsValid());
175 EXPECT_TRUE(rs.Match(
"b"));
176 EXPECT_TRUE(rs.Match(
"ab"));
177 EXPECT_TRUE(rs.Match(
"aab"));
178 EXPECT_FALSE(rs.Match(
""));
179 EXPECT_FALSE(rs.Match(
"bb"));
184 ASSERT_TRUE(re.IsValid());
186 EXPECT_TRUE(rs.Match(
""));
187 EXPECT_TRUE(rs.Match(
"a"));
188 EXPECT_TRUE(rs.Match(
"aa"));
189 EXPECT_TRUE(rs.Match(
"b"));
190 EXPECT_TRUE(rs.Match(
"bb"));
191 EXPECT_TRUE(rs.Match(
"ab"));
192 EXPECT_TRUE(rs.Match(
"aabb"));
193 EXPECT_FALSE(rs.Match(
"ba"));
198 ASSERT_TRUE(re.IsValid());
200 EXPECT_TRUE(rs.Match(
"ab"));
201 EXPECT_TRUE(rs.Match(
"aabb"));
202 EXPECT_TRUE(rs.Match(
"aababb"));
203 EXPECT_FALSE(rs.Match(
""));
204 EXPECT_FALSE(rs.Match(
"aa"));
209 ASSERT_TRUE(re.IsValid());
211 EXPECT_TRUE(rs.Match(
"a"));
212 EXPECT_TRUE(rs.Match(
"aa"));
213 EXPECT_FALSE(rs.Match(
""));
214 EXPECT_FALSE(rs.Match(
"b"));
215 EXPECT_FALSE(rs.Match(
"ab"));
220 ASSERT_TRUE(re.IsValid());
222 EXPECT_TRUE(rs.Match(
"ab"));
223 EXPECT_TRUE(rs.Match(
"aab"));
224 EXPECT_FALSE(rs.Match(
""));
225 EXPECT_FALSE(rs.Match(
"b"));
230 ASSERT_TRUE(re.IsValid());
232 EXPECT_TRUE(rs.Match(
"ab"));
233 EXPECT_TRUE(rs.Match(
"aab"));
234 EXPECT_TRUE(rs.Match(
"abb"));
235 EXPECT_TRUE(rs.Match(
"aabb"));
236 EXPECT_FALSE(rs.Match(
""));
237 EXPECT_FALSE(rs.Match(
"b"));
238 EXPECT_FALSE(rs.Match(
"ba"));
243 ASSERT_TRUE(re.IsValid());
245 EXPECT_TRUE(rs.Match(
"aabb"));
246 EXPECT_TRUE(rs.Match(
"aababb"));
247 EXPECT_FALSE(rs.Match(
""));
248 EXPECT_FALSE(rs.Match(
"ab"));
253 ASSERT_TRUE(re.IsValid());
255 EXPECT_TRUE(rs.Match(
"abbbc"));
256 EXPECT_FALSE(rs.Match(
"ac"));
257 EXPECT_FALSE(rs.Match(
"abc"));
258 EXPECT_FALSE(rs.Match(
"abbc"));
259 EXPECT_FALSE(rs.Match(
"abbbbc"));
263 Regex re(
"a(bc){3}d");
264 ASSERT_TRUE(re.IsValid());
266 EXPECT_TRUE(rs.Match(
"abcbcbcd"));
267 EXPECT_FALSE(rs.Match(
"ad"));
268 EXPECT_FALSE(rs.Match(
"abcd"));
269 EXPECT_FALSE(rs.Match(
"abcbcd"));
270 EXPECT_FALSE(rs.Match(
"abcbcbcbcd"));
274 Regex re(
"a(b|c){3}d");
275 ASSERT_TRUE(re.IsValid());
277 EXPECT_TRUE(rs.Match(
"abbbd"));
278 EXPECT_TRUE(rs.Match(
"acccd"));
279 EXPECT_TRUE(rs.Match(
"abcbd"));
280 EXPECT_FALSE(rs.Match(
"ad"));
281 EXPECT_FALSE(rs.Match(
"abbd"));
282 EXPECT_FALSE(rs.Match(
"accccd"));
283 EXPECT_FALSE(rs.Match(
"abbbbd"));
288 ASSERT_TRUE(re.IsValid());
290 EXPECT_TRUE(rs.Match(
"abbbc"));
291 EXPECT_TRUE(rs.Match(
"abbbbc"));
292 EXPECT_TRUE(rs.Match(
"abbbbbc"));
293 EXPECT_FALSE(rs.Match(
"ac"));
294 EXPECT_FALSE(rs.Match(
"abc"));
295 EXPECT_FALSE(rs.Match(
"abbc"));
299 Regex re(
"a(bc){3,}d");
300 ASSERT_TRUE(re.IsValid());
302 EXPECT_TRUE(rs.Match(
"abcbcbcd"));
303 EXPECT_TRUE(rs.Match(
"abcbcbcbcd"));
304 EXPECT_FALSE(rs.Match(
"ad"));
305 EXPECT_FALSE(rs.Match(
"abcd"));
306 EXPECT_FALSE(rs.Match(
"abcbcd"));
310 Regex re(
"a(b|c){3,}d");
311 ASSERT_TRUE(re.IsValid());
313 EXPECT_TRUE(rs.Match(
"abbbd"));
314 EXPECT_TRUE(rs.Match(
"acccd"));
315 EXPECT_TRUE(rs.Match(
"abcbd"));
316 EXPECT_TRUE(rs.Match(
"accccd"));
317 EXPECT_TRUE(rs.Match(
"abbbbd"));
318 EXPECT_FALSE(rs.Match(
"ad"));
319 EXPECT_FALSE(rs.Match(
"abbd"));
323 Regex re(
"ab{3,5}c");
324 ASSERT_TRUE(re.IsValid());
326 EXPECT_TRUE(rs.Match(
"abbbc"));
327 EXPECT_TRUE(rs.Match(
"abbbbc"));
328 EXPECT_TRUE(rs.Match(
"abbbbbc"));
329 EXPECT_FALSE(rs.Match(
"ac"));
330 EXPECT_FALSE(rs.Match(
"abc"));
331 EXPECT_FALSE(rs.Match(
"abbc"));
332 EXPECT_FALSE(rs.Match(
"abbbbbbc"));
336 Regex re(
"a(bc){3,5}d");
337 ASSERT_TRUE(re.IsValid());
339 EXPECT_TRUE(rs.Match(
"abcbcbcd"));
340 EXPECT_TRUE(rs.Match(
"abcbcbcbcd"));
341 EXPECT_TRUE(rs.Match(
"abcbcbcbcbcd"));
342 EXPECT_FALSE(rs.Match(
"ad"));
343 EXPECT_FALSE(rs.Match(
"abcd"));
344 EXPECT_FALSE(rs.Match(
"abcbcd"));
345 EXPECT_FALSE(rs.Match(
"abcbcbcbcbcbcd"));
349 Regex re(
"a(b|c){3,5}d");
350 ASSERT_TRUE(re.IsValid());
352 EXPECT_TRUE(rs.Match(
"abbbd"));
353 EXPECT_TRUE(rs.Match(
"acccd"));
354 EXPECT_TRUE(rs.Match(
"abcbd"));
355 EXPECT_TRUE(rs.Match(
"accccd"));
356 EXPECT_TRUE(rs.Match(
"abbbbd"));
357 EXPECT_TRUE(rs.Match(
"acccccd"));
358 EXPECT_TRUE(rs.Match(
"abbbbbd"));
359 EXPECT_FALSE(rs.Match(
"ad"));
360 EXPECT_FALSE(rs.Match(
"abbd"));
361 EXPECT_FALSE(rs.Match(
"accccccd"));
362 EXPECT_FALSE(rs.Match(
"abbbbbbd"));
367 Regex re(
"a(b|c){0,3}d");
368 ASSERT_TRUE(re.IsValid());
370 EXPECT_TRUE(rs.Match(
"ad"));
371 EXPECT_TRUE(rs.Match(
"abd"));
372 EXPECT_TRUE(rs.Match(
"acd"));
373 EXPECT_TRUE(rs.Match(
"abbd"));
374 EXPECT_TRUE(rs.Match(
"accd"));
375 EXPECT_TRUE(rs.Match(
"abcd"));
376 EXPECT_TRUE(rs.Match(
"abbbd"));
377 EXPECT_TRUE(rs.Match(
"acccd"));
378 EXPECT_FALSE(rs.Match(
"abbbbd"));
379 EXPECT_FALSE(rs.Match(
"add"));
380 EXPECT_FALSE(rs.Match(
"accccd"));
381 EXPECT_FALSE(rs.Match(
"abcbcd"));
386 Regex re(
"a(b|c){0,}d");
387 ASSERT_TRUE(re.IsValid());
389 EXPECT_TRUE(rs.Match(
"ad"));
390 EXPECT_TRUE(rs.Match(
"abd"));
391 EXPECT_TRUE(rs.Match(
"acd"));
392 EXPECT_TRUE(rs.Match(
"abbd"));
393 EXPECT_TRUE(rs.Match(
"accd"));
394 EXPECT_TRUE(rs.Match(
"abcd"));
395 EXPECT_TRUE(rs.Match(
"abbbd"));
396 EXPECT_TRUE(rs.Match(
"acccd"));
397 EXPECT_TRUE(rs.Match(
"abbbbd"));
398 EXPECT_TRUE(rs.Match(
"accccd"));
399 EXPECT_TRUE(rs.Match(
"abcbcd"));
400 EXPECT_FALSE(rs.Match(
"add"));
401 EXPECT_FALSE(rs.Match(
"aad"));
404 #define EURO "\xE2\x82\xAC" // "\xE2\x82\xAC" is UTF-8 rsquence of Euro sign U+20AC 408 ASSERT_TRUE(re.IsValid());
410 EXPECT_TRUE(rs.Match(
"a" EURO "b"));
411 EXPECT_TRUE(rs.Match(
"a" EURO EURO "b"));
412 EXPECT_FALSE(rs.Match(
"a?b"));
413 EXPECT_FALSE(rs.Match(
"a" EURO
"\xAC" "b"));
418 ASSERT_TRUE(re.IsValid());
420 EXPECT_TRUE(rs.Match(
"a"));
421 EXPECT_TRUE(rs.Match(
"b"));
422 EXPECT_TRUE(rs.Match(
EURO));
423 EXPECT_FALSE(rs.Match(
""));
424 EXPECT_FALSE(rs.Match(
"aa"));
429 ASSERT_TRUE(re.IsValid());
431 EXPECT_TRUE(rs.Match(
"a"));
432 EXPECT_TRUE(rs.Match(
"b"));
433 EXPECT_TRUE(rs.Match(
"c"));
434 EXPECT_FALSE(rs.Match(
""));
435 EXPECT_FALSE(rs.Match(
"`"));
436 EXPECT_FALSE(rs.Match(
"d"));
437 EXPECT_FALSE(rs.Match(
"aa"));
442 ASSERT_TRUE(re.IsValid());
444 EXPECT_TRUE(rs.Match(
"`"));
445 EXPECT_TRUE(rs.Match(
"d"));
446 EXPECT_FALSE(rs.Match(
"a"));
447 EXPECT_FALSE(rs.Match(
"b"));
448 EXPECT_FALSE(rs.Match(
"c"));
449 EXPECT_FALSE(rs.Match(
""));
450 EXPECT_FALSE(rs.Match(
"aa"));
455 ASSERT_TRUE(re.IsValid());
457 EXPECT_TRUE(rs.Match(
"a"));
458 EXPECT_TRUE(rs.Match(
"b"));
459 EXPECT_TRUE(rs.Match(
"c"));
460 EXPECT_FALSE(rs.Match(
""));
461 EXPECT_FALSE(rs.Match(
"`"));
462 EXPECT_FALSE(rs.Match(
"d"));
463 EXPECT_FALSE(rs.Match(
"aa"));
468 ASSERT_TRUE(re.IsValid());
470 EXPECT_TRUE(rs.Match(
"`"));
471 EXPECT_TRUE(rs.Match(
"d"));
472 EXPECT_FALSE(rs.Match(
"a"));
473 EXPECT_FALSE(rs.Match(
"b"));
474 EXPECT_FALSE(rs.Match(
"c"));
475 EXPECT_FALSE(rs.Match(
""));
476 EXPECT_FALSE(rs.Match(
"aa"));
481 ASSERT_TRUE(re.IsValid());
483 EXPECT_TRUE(rs.Match(
"-"));
484 EXPECT_FALSE(rs.Match(
""));
485 EXPECT_FALSE(rs.Match(
"a"));
490 ASSERT_TRUE(re.IsValid());
492 EXPECT_TRUE(rs.Match(
"a"));
493 EXPECT_TRUE(rs.Match(
"-"));
494 EXPECT_FALSE(rs.Match(
""));
495 EXPECT_FALSE(rs.Match(
"`"));
496 EXPECT_FALSE(rs.Match(
"b"));
501 ASSERT_TRUE(re.IsValid());
503 EXPECT_TRUE(rs.Match(
"a"));
504 EXPECT_TRUE(rs.Match(
"-"));
505 EXPECT_FALSE(rs.Match(
""));
506 EXPECT_FALSE(rs.Match(
"`"));
507 EXPECT_FALSE(rs.Match(
"b"));
511 Regex re(
"[a-zA-Z0-9]*");
512 ASSERT_TRUE(re.IsValid());
514 EXPECT_TRUE(rs.Match(
"Milo"));
515 EXPECT_TRUE(rs.Match(
"MT19937"));
516 EXPECT_TRUE(rs.Match(
"43"));
517 EXPECT_FALSE(rs.Match(
"a_b"));
518 EXPECT_FALSE(rs.Match(
"!"));
523 ASSERT_TRUE(re.IsValid());
525 EXPECT_TRUE(rs.Search(
"abc"));
526 EXPECT_TRUE(rs.Search(
"_abc"));
527 EXPECT_TRUE(rs.Search(
"abc_"));
528 EXPECT_TRUE(rs.Search(
"_abc_"));
529 EXPECT_TRUE(rs.Search(
"__abc__"));
530 EXPECT_TRUE(rs.Search(
"abcabc"));
531 EXPECT_FALSE(rs.Search(
"a"));
532 EXPECT_FALSE(rs.Search(
"ab"));
533 EXPECT_FALSE(rs.Search(
"bc"));
534 EXPECT_FALSE(rs.Search(
"cba"));
539 ASSERT_TRUE(re.IsValid());
541 EXPECT_TRUE(rs.Search(
"abc"));
542 EXPECT_TRUE(rs.Search(
"abc_"));
543 EXPECT_TRUE(rs.Search(
"abcabc"));
544 EXPECT_FALSE(rs.Search(
"_abc"));
545 EXPECT_FALSE(rs.Search(
"_abc_"));
546 EXPECT_FALSE(rs.Search(
"a"));
547 EXPECT_FALSE(rs.Search(
"ab"));
548 EXPECT_FALSE(rs.Search(
"bc"));
549 EXPECT_FALSE(rs.Search(
"cba"));
554 ASSERT_TRUE(re.IsValid());
556 EXPECT_TRUE(rs.Search(
"abc"));
557 EXPECT_TRUE(rs.Search(
"_abc"));
558 EXPECT_TRUE(rs.Search(
"abcabc"));
559 EXPECT_FALSE(rs.Search(
"abc_"));
560 EXPECT_FALSE(rs.Search(
"_abc_"));
561 EXPECT_FALSE(rs.Search(
"a"));
562 EXPECT_FALSE(rs.Search(
"ab"));
563 EXPECT_FALSE(rs.Search(
"bc"));
564 EXPECT_FALSE(rs.Search(
"cba"));
569 ASSERT_TRUE(re.IsValid());
571 EXPECT_TRUE(rs.Search(
"abc"));
572 EXPECT_FALSE(rs.Search(
""));
573 EXPECT_FALSE(rs.Search(
"a"));
574 EXPECT_FALSE(rs.Search(
"b"));
575 EXPECT_FALSE(rs.Search(
"ab"));
576 EXPECT_FALSE(rs.Search(
"abcd"));
580 const char*
s =
"\\^\\$\\|\\(\\)\\?\\*\\+\\.\\[\\]\\{\\}\\\\\\f\\n\\r\\t\\v[\\b][\\[][\\]]";
582 ASSERT_TRUE(re.IsValid());
584 EXPECT_TRUE(rs.Match(
"^$|()?*+.[]{}\\\x0C\n\r\t\x0B\b[]"));
585 EXPECT_FALSE(rs.Match(s));
589 #define TEST_INVALID(s) \ 592 EXPECT_FALSE(re.IsValid());\ 629 Regex re(
"^[0-9]+(\\\\.[0-9]+){0,2}");
630 EXPECT_TRUE(re.IsValid());
634 Regex re(
"[0-9]{99999}");
635 ASSERT_TRUE(re.IsValid());
GenericRegexSearch< Regex > RegexSearch
GenericRegex< UTF8<> > Regex