Home | History | Annotate | Download | only in testing

Lines Matching full:re2

2 // Copyright 2002-2009 The RE2 Authors.  All Rights Reserved.
14 #include "re2/re2.h"
15 #include "re2/regexp.h"
19 namespace re2 {
21 TEST(RE2, HexTests) {
28 CHECK(RE2::FullMatch(#value, "([0-9a-fA-F]+)[uUlL]*", RE2::Hex(&v))); \
30 CHECK(RE2::FullMatch("0x" #value, "([0-9a-fA-FxX]+)[uUlL]*", RE2::CRadix(&v))); \
46 TEST(RE2, OctalTests) {
52 CHECK(RE2::FullMatch(#value, "([0-7]+)[uUlL]*", RE2::Octal(&v))); \
54 CHECK(RE2::FullMatch("0" #value, "([0-9a-fA-FxX]+)[uUlL]*", RE2::CRadix(&v))); \
70 TEST(RE2, DecimalTests) {
76 CHECK(RE2::FullMatch(#value, "(-?[0-9]+)[uUlL]*", &v)); \
78 CHECK(RE2::FullMatch(#value, "(-?[0-9a-fA-FxX]+)[uUlL]*", RE2::CRadix(&v))); \
94 TEST(RE2, Replace) {
179 CHECK(RE2::Replace(&one, t->regexp, t->rewrite));
182 CHECK_EQ(RE2::GlobalReplace(&all, t->regexp, t->rewrite), t->greplace_count)
191 RE2 exp(regexp);
212 TEST(RE2, Extract) {
217 CHECK(RE2::Extract("boris@kremvax.ru", "(.*)@([^.]*)", "\\2!\\1", &s));
220 CHECK(RE2::Extract("foo", ".*", "'\\0'", &s));
223 CHECK(!RE2::Extract("baz", "bar", "'\\0'", &s));
227 TEST(RE2, Consume) {
230 RE2 r("\\s*(\\w+)"); // matches a word, possibly proceeded by whitespace
236 CHECK(RE2::Consume(&input, r, &word));
238 CHECK(RE2::Consume(&input, r, &word));
240 CHECK(! RE2::Consume(&input, r, &word)) << " input: " << input;
243 TEST(RE2, ConsumeN) {
247 RE2::Arg argv[2];
248 const RE2::Arg* const args[2] = { &argv[0], &argv[1] };
251 EXPECT_TRUE(RE2::ConsumeN(&input, "\\s*(\\w+)", args, 0)); // Skips "one".
256 EXPECT_TRUE(RE2::ConsumeN(&input, "\\s*(\\w+)", args, 1));
262 EXPECT_TRUE(RE2::ConsumeN(&input, "\\s*(\\w+)\\s*(\\d+)", args, 2));
267 TEST(RE2, FindAndConsume) {
270 RE2 r("(\\w+)"); // matches a word
276 CHECK(RE2::FindAndConsume(&input, r, &word));
278 CHECK(RE2::FindAndConsume(&input, r, &word));
280 CHECK(RE2::FindAndConsume(&input, r, &word));
282 CHECK(! RE2::FindAndConsume(&input, r, &word));
288 CHECK(RE2::FindAndConsume(&input, "aaa"));
292 TEST(RE2, FindAndConsumeN) {
296 RE2::Arg argv[2];
297 const RE2::Arg* const args[2] = { &argv[0], &argv[1] };
300 EXPECT_TRUE(RE2::FindAndConsumeN(&input, "(\\w+)", args, 0)); // Skips "one".
305 EXPECT_TRUE(RE2::FindAndConsumeN(&input, "(\\w+)", args, 1));
311 EXPECT_TRUE(RE2::FindAndConsumeN(&input, "(\\w+)\\s*(\\d+)", args, 2));
316 TEST(RE2, MatchNumberPeculiarity) {
319 RE2 r("(foo)|(bar)|(baz)");
324 CHECK(RE2::PartialMatch("foo", r, &word1, &word2, &word3));
328 CHECK(RE2::PartialMatch("bar", r, &word1, &word2, &word3));
332 CHECK(RE2::PartialMatch("baz", r, &word1, &word2, &word3));
336 CHECK(!RE2::PartialMatch("f", r, &word1, &word2, &word3));
339 CHECK(RE2::FullMatch("hello", "(foo)|hello", &a));
343 TEST(RE2, Match) {
344 RE2 re("((\\w+):([0-9]+))"); // extracts host and port
349 CHECK(!re.Match(s, 0, s.size(), RE2::UNANCHORED,
354 CHECK(re.Match(s, 0, s.size(), RE2::UNANCHORED,
363 CHECK(RE2::PartialMatch("a chrisr:9000 here", re, &all, &host, &port));
378 RE2 re("([a-zA-Z0-9]|-)+(\\.([a-zA-Z0-9]|-)+)*(\\.)?", RE2::Quiet);
379 RE2::FullMatch(domain, re);
385 const RE2::Options& options = RE2::DefaultOptions) {
386 string quoted = RE2::QuoteMeta(unquoted);
387 RE2 re(quoted, options);
388 EXPECT_TRUE_M(RE2::FullMatch(unquoted, re),
395 const RE2::Options& options = RE2::DefaultOptions) {
396 string quoted = RE2::QuoteMeta(unquoted);
397 RE2 re(quoted, options);
398 EXPECT_FALSE_M(RE2::FullMatch(should_not_match, re),
432 TestQuoteMeta("3\xb2 = 9", RE2::Latin1);
463 RE2 re_simple("simple regexp");
464 RE2 re_medium("medium.*regexp");
465 RE2 re_complex("hard.{1,128}regexp");
483 CHECK(!RE2(empties[i]).Match("abc", 0, 3, RE2::UNANCHORED, NULL, 0));
489 RE2 re("(hello world)");
496 RE2 re("(?P<A>expr(?P<B>expr)(?P<C>expr))((expr)(?P<D>expr))");
507 TEST(RE2, FullMatchWithNoArgs) {
508 CHECK(RE2::FullMatch("h", "h"));
509 CHECK(RE2::FullMatch("hello", "hello"));
510 CHECK(RE2::FullMatch("hello", "h.*o"));
511 CHECK(!RE2::FullMatch("othello", "h.*o")); // Must be anchored at front
512 CHECK(!RE2::FullMatch("hello!", "h.*o")); // Must be anchored at end
515 TEST(RE2, PartialMatch) {
516 CHECK(RE2::PartialMatch("x", "x"));
517 CHECK(RE2::PartialMatch("hello", "h.*o"));
518 CHECK(RE2::PartialMatch("othello", "h.*o"));
519 CHECK(RE2::PartialMatch("hello!", "h.*o"));
520 CHECK(RE2::PartialMatch("x", "((((((((((((((((((((x))))))))))))))))))))"));
523 TEST(RE2, PartialMatchN) {
524 RE2::Arg argv[2];
525 const RE2::Arg* const args[2] = { &argv[0], &argv[1] };
528 EXPECT_TRUE(RE2::PartialMatchN("hello", "e.*o", args, 0));
529 EXPECT_FALSE(RE2::PartialMatchN("othello", "a.*o", args, 0));
534 EXPECT_TRUE(RE2::PartialMatchN("1001 nights", "(\\d+)", args, 1));
536 EXPECT_FALSE(RE2::PartialMatchN("three", "(\\d+)", args, 1));
541 EXPECT_TRUE(RE2::PartialMatchN("answer: 42:life", "(\\d+):(\\w+)", args, 2));
544 EXPECT_FALSE(RE2::PartialMatchN("hi1", "(\\w+)(1)", args, 2));
547 TEST(RE2, FullMatchZeroArg) {
549 CHECK(RE2::FullMatch("1001", "\\d+"));
552 TEST(RE2, FullMatchOneArg) {
556 CHECK(RE2::FullMatch("1001", "(\\d+)", &i));
558 CHECK(RE2::FullMatch("-123", "(-?\\d+)", &i));
560 CHECK(!RE2::FullMatch("10", "()\\d+", &i));
561 CHECK(!RE2::FullMatch("1234567890123456789012345678901234567890",
565 TEST(RE2, FullMatchIntegerArg) {
569 CHECK(RE2::FullMatch("1234", "1(\\d*)4", &i));
571 CHECK(RE2::FullMatch("1234", "(\\d)\\d+", &i));
573 CHECK(RE2::FullMatch("-1234", "(-\\d)\\d+", &i));
575 CHECK(RE2
577 CHECK(RE2::PartialMatch("-1234", "(-\\d)", &i));
581 TEST(RE2, FullMatchStringArg) {
584 CHECK(RE2::FullMatch("hello", "h(.*)o", &s));
588 TEST(RE2, FullMatchStringPieceArg) {
592 CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &sp, &i));
598 TEST(RE2, FullMatchMultiArg) {
602 CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i));
607 TEST(RE2, FullMatchN) {
608 RE2::Arg argv[2];
609 const RE2::Arg* const args[2] = { &argv[0], &argv[1] };
612 EXPECT_TRUE(RE2::FullMatchN("hello", "h.*o", args, 0));
613 EXPECT_FALSE(RE2::FullMatchN("othello", "h.*o", args, 0));
618 EXPECT_TRUE(RE2::FullMatchN("1001", "(\\d+)", args, 1));
620 EXPECT_FALSE(RE2::FullMatchN("three", "(\\d+)", args, 1));
625 EXPECT_TRUE(RE2::FullMatchN("42:life", "(\\d+):(\\w+)", args, 2));
628 EXPECT_FALSE(RE2::FullMatchN("hi1", "(\\w+)(1)", args, 2));
631 TEST(RE2, FullMatchIgnoredArg) {
635 CHECK(RE2::FullMatch("ruby:1234", "(\\w+)(:)(\\d+)", &s, (void*)NULL, &i));
640 TEST(RE2, FullMatchTypedNullArg) {
644 CHECK(RE2::FullMatch("hello", "he(.*)lo", (char*)NULL));
645 CHECK(RE2::FullMatch("hello", "h(.*)o", (string*)NULL));
646 CHECK(RE2::FullMatch("hello", "h(.*)o", (StringPiece*)NULL));
647 CHECK(RE2::FullMatch("1234", "(.*)", (int*)NULL));
648 CHECK(RE2::FullMatch("1234567890123456", "(.*)", (long long*)NULL));
649 CHECK(RE2::FullMatch("123.4567890123456", "(.*)", (double*)NULL));
650 CHECK(RE2::FullMatch("123.4567890123456", "(.*)", (float*)NULL));
653 CHECK(!RE2::FullMatch("hello", "h(.*)lo", &s, (char*)NULL));
654 CHECK(!RE2::FullMatch("hello", "(.*)", (int*)NULL));
655 CHECK(!RE2::FullMatch("1234567890123456", "(.*)", (int*)NULL));
656 CHECK(!RE2::FullMatch("hello", "(.*)", (double*)NULL));
657 CHECK(!RE2::FullMatch("hello", "(.*)", (float*)NULL));
662 TEST(RE2, NULTerminated) {
678 CHECK(RE2::FullMatch(StringPiece(v + pagesize - 1, 1), "(.*)", &x));
682 TEST(RE2, FullMatchTypeTests) {
687 CHECK(RE2::FullMatch("Hello", "(H)ello", &c));
692 CHECK(RE2::FullMatch("Hello", "(H)ello", &c));
697 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
698 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100);
699 CHECK(RE2::FullMatch("32767", "(-?\\d+)", &v)); CHECK_EQ(v, 32767);
700 CHECK(RE2::FullMatch("-32768", "(-?\\d+)", &v)); CHECK_EQ(v, -32768);
701 CHECK(!RE2::FullMatch("-32769", "(-?\\d+)", &v));
702 CHECK(!RE2::FullMatch("32768", "(-?\\d+)", &v));
706 CHECK(RE2::FullMatch("100", "(\\d+)", &v)); CHECK_EQ(v, 100);
707 CHECK(RE2::FullMatch("32767", "(\\d+)", &v)); CHECK_EQ(v, 32767);
708 CHECK(RE2::FullMatch("65535", "(\\d+)", &v)); CHECK_EQ(v, 65535);
709 CHECK(!RE2::FullMatch("65536", "(\\d+)", &v));
715 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
716 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100);
717 CHECK(RE2::FullMatch("2147483647", "(-?\\d+)", &v)); CHECK_EQ(v, max);
718 CHECK(RE2::FullMatch("-2147483648", "(-?\\d+)", &v)); CHECK_EQ(v, min);
719 CHECK(!RE2::FullMatch("-2147483649", "(-?\\d+)", &v));
720 CHECK(!RE2::FullMatch("2147483648", "(-?\\d+)", &v));
722 CHECK(RE2::FullMatch(zeros + "2147483647", "(-?\\d+)", &v));
724 CHECK(RE2::FullMatch("-" + zeros + "2147483648", "(-?\\d+)", &v));
727 CHECK(!RE2::FullMatch("-" + zeros + "2147483649", "(-?\\d+)", &v));
728 CHECK(RE2::FullMatch("0x7fffffff", "(.*)", RE2::CRadix(&v)));
730 CHECK(!RE2::FullMatch("000x7fffffff", "(.*)", RE2::CRadix(&v)));
735 CHECK(RE2::FullMatch("100", "(\\d+)", &v)); CHECK_EQ(v, 100);
736 CHECK(RE2::FullMatch("4294967295", "(\\d+)", &v)); CHECK_EQ(v, max);
737 CHECK(!RE2::FullMatch("4294967296", "(\\d+)", &v));
738 CHECK(!RE2::FullMatch("-1", "(\\d+)", &v));
740 CHECK(RE2::FullMatch(zeros + "4294967295", "(\\d+)", &v)); CHECK_EQ(v, max);
748 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
749 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v)); CHECK_EQ(v, -100);
752 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
755 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, min);
760 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
765 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
773 CHECK(RE2::FullMatch("100", "(-?\\d+)", &v)); CHECK_EQ(v, 100);
774 CHECK(RE2::FullMatch("-100", "(-?\\d+)", &v2)); CHECK_EQ(v2, -100);
777 CHECK(RE2::FullMatch(buf, "(-?\\d+)", &v)); CHECK_EQ(v, max);
781 CHECK(!RE2::FullMatch(buf, "(-?\\d+)", &v));
785 TEST(RE2, FloatingPointFullMatchTypes) {
789 CHECK(RE2::FullMatch("100", "(.*)", &v)); CHECK_EQ(v, 100);
790 CHECK(RE2::FullMatch("-100.", "(.*)", &v)); CHECK_EQ(v, -100);
791 CHECK(RE2::FullMatch("1e23", "(.*)", &v)); CHECK_EQ(v, float(1e23));
793 CHECK(RE2::FullMatch(zeros + "1e23", "(.*)", &v));
808 CHECK(RE2::FullMatch("0.1", "(.*)", &v));
810 CHECK(RE2::FullMatch("6700000000081920.1", "(.*)", &v));
816 CHECK(RE2::FullMatch("100", "(.*)", &v)); CHECK_EQ(v, 100);
817 CHECK(RE2::FullMatch("-100.", "(.*)", &v)); CHECK_EQ(v, -100);
818 CHECK(RE2::FullMatch("1e23", "(.*)", &v)); CHECK_EQ(v, 1e23);
819 CHECK(RE2::FullMatch(zeros + "1e23", "(.*)", &v));
822 CHECK(RE2::FullMatch("0.1", "(.*)", &v));
824 CHECK(RE2::FullMatch("1.00000005960464485", "(.*)", &v));
830 TEST(RE2, FullMatchAnchored) {
833 CHECK(!RE2::FullMatch("x1001", "(\\d+)", &i));
834 CHECK(!RE2::FullMatch("1001x", "(\\d+)", &i));
835 CHECK(RE2::FullMatch("x1001", "x(\\d+)", &i)); CHECK_EQ(i, 1001);
836 CHECK(RE2::FullMatch("1001x", "(\\d+)x", &i)); CHECK_EQ(i, 1001);
839 TEST(RE2, FullMatchBraces) {
841 CHECK(RE2::FullMatch("0abcd", "[0-9a-f+.-]{5,}"));
842 CHECK(RE2::FullMatch("0abcde", "[0-9a-f+.-]{5,}"));
843 CHECK(!RE2::FullMatch("0abc", "[0-9a-f+.-]{5,}"));
846 TEST(RE2, Complicated) {
847 // Complicated RE2
848 CHECK(RE2::FullMatch("foo", "foo|bar|[A-Z]"));
849 CHECK(RE2::FullMatch("bar", "foo|bar|[A-Z]"));
850 CHECK(RE2::FullMatch("X", "foo|bar|[A-Z]"));
851 CHECK(!RE2::FullMatch("XY", "foo|bar|[A-Z]"));
854 TEST(RE2, FullMatchEnd) {
856 CHECK(RE2::FullMatch("fo", "fo|foo"));
857 CHECK(RE2::FullMatch("foo", "fo|foo"));
858 CHECK(RE2::FullMatch("fo", "fo|foo$"));
859 CHECK(RE2::FullMatch("foo", "fo|foo$"));
860 CHECK(RE2::FullMatch("foo", "foo$"));
861 CHECK(!RE2::FullMatch("foo$bar", "foo\\$"));
862 CHECK(!RE2::FullMatch("fox", "fo|bar"));
869 CHECK(!RE2::PartialMatch("foo\n", "foo$"));
873 TEST(RE2, FullMatchArgCount) {
876 CHECK(RE2::FullMatch("", ""));
879 CHECK(RE2::FullMatch("1",
885 CHECK(RE2::FullMatch("12",
892 CHECK(RE2::FullMatch("123",
900 CHECK(RE2::FullMatch("1234",
909 CHECK(RE2::FullMatch("12345",
920 CHECK(RE2::FullMatch("123456",
932 CHECK(RE2::FullMatch("1234567",
945 CHECK(RE2::FullMatch("1234567890123456",
970 TEST(RE2, Accessors) {
974 const RE2 re(kPattern);
978 // Check RE2 error field.
980 RE2 re("foo");
983 CHECK(re.error_code() == RE2::NoError);
987 TEST(RE2, UTF8) {
1004 RE2 re_test1(".........", RE2::Latin1);
1005 CHECK(RE2::FullMatch(utf8_string, re_test1));
1006 RE2 re_test2("...");
1007 CHECK(RE2::FullMatch(utf8_string, re_test2));
1012 RE2 re_test3("(.)", RE2::Latin1);
1013 CHECK(RE2::PartialMatch(utf8_string, re_test3, &s));
1015 RE2 re_test4("(.)");
1016 CHECK(RE2::PartialMatch(utf8_string, re_test4, &s));
1020 RE2 re_test5(utf8_string, RE2::Latin1);
1021 CHECK(RE2::FullMatch(utf8_string, re_test5));
1022 RE2 re_test6(utf8_string);
1023 CHECK(RE2::FullMatch(utf8_string, re_test6));
1026 RE2 re_test7(utf8_pattern, RE2::Latin1);
1027 CHECK(!RE2::FullMatch(utf8_string, re_test7));
1028 RE2 re_test8(utf8_pattern);
1029 CHECK(RE2::FullMatch(utf8_string, re_test8));
1032 TEST(RE2, UngreedyUTF8) {
1039 RE2 match_sentence(pattern, RE2::Latin1);
1040 RE2 match_sentence_re(pattern);
1042 CHECK(!RE2::FullMatch(target, match_sentence));
1043 CHECK(!RE2::FullMatch(target, match_sentence_re));
1048 RE2 match_sentence(pattern, RE2::Latin1);
1050 RE2 match_sentence_re(pattern);
1052 CHECK(!RE2::FullMatch(target, match_sentence));
1053 CHECK(!RE2::FullMatch(target, match_sentence_re));
1057 TEST(RE2, Rejects) {
1058 { RE2 re("a\\1", RE2::Quiet); CHECK(!re.ok()); }
1060 RE2 re("a[x", RE2::Quiet);
1064 RE2 re("a[z-a]", RE2::Quiet);
1068 RE2 re("a[[:foobar:]]", RE2::Quiet);
1072 RE2 re("a(b", RE2::Quiet);
1076 RE2 re("a\\", RE2::Quiet);
1081 TEST(RE2, NoCrash) {
1084 RE2 re("a\\", RE2::Quiet);
1086 CHECK(!RE2::PartialMatch("a\\b", re));
1091 RE2 re("(((.{100}){100}){100}){100}", RE2::Quiet);
1093 CHECK(!RE2::PartialMatch("aaa", re));
1098 RE2 re(".{512}x", RE2::Quiet);
1103 CHECK(RE2::PartialMatch(s, re));
1107 TEST(RE2, Recursion) {
1109 // This test is PCRE-legacy -- there's no recursion in RE2.
1118 TEST(RE2, BigCountedRepetition) {
1120 RE2::Options opt;
1123 RE2 re(".{512}x", opt);
1128 CHECK(RE2::PartialMatch(s, re));
1131 TEST(RE2, DeepRecursion) {
1135 // Again, a PCRE legacy test. RE2 doesn't recurse.
1140 RE2 re("((?:\\s|xx.*\n|x[*](?:\n|.)*?[*]x)*)");
1141 CHECK(RE2::FullMatch(comment, re));
1151 EXPECT_TRUE(RE2::PartialMatch(sp, "(?i)([wand]{5})", &result));
1152 EXPECT_TRUE(RE2::FindAndConsume(&sp, "(?i)([wand]{5})", &result));
1155 // RE2 should permit implicit conversions from string, StringPiece, const char*,
1157 TEST(RE2, ImplicitConversions) {
1161 EXPECT_TRUE(RE2::PartialMatch("e", re_string));
1162 EXPECT_TRUE(RE2::PartialMatch("e", re_stringpiece));
1163 EXPECT_TRUE(RE2::PartialMatch("e", re_cstring));
1164 EXPECT_TRUE(RE2::PartialMatch("e", "."));
1168 TEST(RE2, CL8622304) {
1171 EXPECT_TRUE(RE2::FullMatch("D", "([^\\\\])")); // ok
1172 EXPECT_TRUE(RE2::FullMatch("D", "([^\\\\])", &dir)); // fails
1176 EXPECT_TRUE(RE2::PartialMatch("bar:1,0x2F,030,4,5;baz:true;fooby:false,true",
1185 // Check that RE2 returns correct regexp pieces on error.
1211 TEST(RE2, ErrorArgs) {
1213 RE2 re(error_tests[i].regexp, RE2::Quiet);
1231 TEST(RE2, NeverNewline) {
1232 RE2::Options opt;
1236 RE2 re(t.regexp, opt);
1248 TEST(RE2, NeverCapture) {
1249 RE2::Options opt;
1251 RE2 re("(r)(e)", opt);
1259 TEST(RE2, BitstateCaptureBug) {
1260 RE2::Options opt;
1262 RE2 re("(_________$)", opt);
1264 EXPECT_FALSE(re.Match(s, 0, s.size(), RE2::UNANCHORED, NULL, 0));
1268 TEST(RE2, UnicodeClasses) {
1272 EXPECT_TRUE(RE2::FullMatch("A", "\\p{L}"));
1273 EXPECT_TRUE(RE2::FullMatch("A", "\\p{Lu}"));
1274 EXPECT_FALSE(RE2::FullMatch("A", "\\p{Ll}"));
1275 EXPECT_FALSE(RE2::FullMatch("A", "\\P{L}"));
1276 EXPECT_FALSE(RE2::FullMatch("A", "\\P{Lu}"));
1277 EXPECT_TRUE(RE2::FullMatch("A", "\\P{Ll}"));
1279 EXPECT_TRUE(RE2::FullMatch("?", "\\p{L}"));
1280 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Lu}"));
1281 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Ll}"));
1282 EXPECT_FALSE(RE2::FullMatch("?", "\\P{L}"));
1283 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Lu}"));
1284 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Ll}"));
1286 EXPECT_TRUE(RE2::FullMatch("?", "\\p{L}"));
1287 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Lu}"));
1288 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Ll}"));
1289 EXPECT_FALSE(RE2::FullMatch("?", "\\P{L}"));
1290 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Lu}"));
1291 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Ll}"));
1293 EXPECT_TRUE(RE2::FullMatch("?", "\\p{L}"));
1294 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Lu}"));
1295 EXPECT_FALSE(RE2::FullMatch("?", "\\p{Ll}"));
1296 EXPECT_FALSE(RE2::FullMatch("?", "\\P{L}"));
1297 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Lu}"));
1298 EXPECT_TRUE(RE2::FullMatch("?", "\\P{Ll}"));
1300 EXPECT_TRUE(RE2::PartialMatch(str, "(.).*?(.).*?(.)", &a, &b, &c));
1305 EXPECT_TRUE(RE2::PartialMatch(str, "(.).*?([\\p{L}]).*?(.)", &a, &b, &c));
1310 EXPECT_FALSE(RE2::PartialMatch(str, "\\P{L}"));
1312 EXPECT_TRUE(RE2::PartialMatch(str, "(.).*?([\\p{Lu}]).*?(.)", &a, &b, &c));
1317 EXPECT_FALSE(RE2::PartialMatch(str, "[^\\p{Lu}\\p{Lo}]"));
1319 EXPECT_TRUE(RE2::PartialMatch(str, ".*(.).*?([\\p{Lu}\\p{Lo}]).*?(.)", &a, &b, &c));
1326 TEST(RE2, NullVsEmptyString) {
1327 RE2 re2(".*");
1329 EXPECT_TRUE(RE2::FullMatch(v1, re2));
1332 EXPECT_TRUE(RE2::FullMatch(v2, re2));
1336 TEST(RE2, Bug1816809) {
1337 RE2 re("(((((llx((-3)|(4)))(;(llx((-3)|(4))))*))))");
1340 EXPECT_TRUE(RE2::Consume(&piece, re, &x));
1344 TEST(RE2, Bug3061120) {
1345 RE2 re("(?i)\\W");
1346 EXPECT_FALSE(RE2::PartialMatch("x", re)); // always worked
1347 EXPECT_FALSE(RE2::PartialMatch("k", re)); // broke because of kelvin
1348 EXPECT_FALSE(RE2::PartialMatch("s", re)); // broke because of latin long s
1351 TEST(RE2, CapturingGroupNames) {
1354 RE2 re("((abc)(?P<G2>)|((e+)(?P<G2>.*)(?P<G1>u+)))");
1364 TEST(RE2, RegexpToStringLossOfAnchor) {
1365 EXPECT_EQ(RE2("^[a-c]at", RE2::POSIX).Regexp()->ToString(), "^[a-c]at");
1366 EXPECT_EQ(RE2("^[a-c]at").Regexp()->ToString(), "(?-m:^)[a-c]at");
1367 EXPECT_EQ(RE2("ca[t-z]$", RE2::POSIX).Regexp()->ToString(), "ca[t-z]$");
1368 EXPECT_EQ(RE2("ca[t-z]$").Regexp()->ToString(), "ca[t-z](?-m:$)");
1371 } // namespace re2