diff options
author | iblinnikov <iblinnikov@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:07 +0300 |
commit | ed2bfbca3e30e641448ad350b4305c69e12aff88 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/regex/pire/ut/regexp_ut.cpp | |
parent | b420f761873190614f41ed39c6d96bd3dc14fd00 (diff) | |
download | ydb-ed2bfbca3e30e641448ad350b4305c69e12aff88.tar.gz |
Restoring authorship annotation for <iblinnikov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/regex/pire/ut/regexp_ut.cpp')
-rw-r--r-- | library/cpp/regex/pire/ut/regexp_ut.cpp | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/library/cpp/regex/pire/ut/regexp_ut.cpp b/library/cpp/regex/pire/ut/regexp_ut.cpp index 19694cfe59..e7206de9ad 100644 --- a/library/cpp/regex/pire/ut/regexp_ut.cpp +++ b/library/cpp/regex/pire/ut/regexp_ut.cpp @@ -216,95 +216,95 @@ Y_UNIT_TEST_SUITE(TRegExp) { UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("xx")); } - Y_UNIT_TEST(SlowCapture) { - TSlowCapturingFsm fsm("^http://vk(ontakte[.]ru|[.]com)/id(\\d+)([^0-9]|$)", - TFsm::TOptions().SetCapture(2)); - TSlowSearcher searcher(fsm); - searcher.Search("http://vkontakte.ru/id100500"); - UNIT_ASSERT(searcher.Captured()); + Y_UNIT_TEST(SlowCapture) { + TSlowCapturingFsm fsm("^http://vk(ontakte[.]ru|[.]com)/id(\\d+)([^0-9]|$)", + TFsm::TOptions().SetCapture(2)); + TSlowSearcher searcher(fsm); + searcher.Search("http://vkontakte.ru/id100500"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("100500")); - } - - Y_UNIT_TEST(SlowCaptureGreedy) { - TSlowCapturingFsm fsm(".*(pref.*suff)"); - TSlowSearcher searcher(fsm); - searcher.Search("pref ala bla pref cla suff dla"); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(SlowCaptureGreedy) { + TSlowCapturingFsm fsm(".*(pref.*suff)"); + TSlowSearcher searcher(fsm); + searcher.Search("pref ala bla pref cla suff dla"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("pref cla suff")); - } - - Y_UNIT_TEST(SlowCaptureNonGreedy) { - TSlowCapturingFsm fsm(".*?(pref.*suff)"); - TSlowSearcher searcher(fsm); - searcher.Search("pref ala bla pref cla suff dla"); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(SlowCaptureNonGreedy) { + TSlowCapturingFsm fsm(".*?(pref.*suff)"); + TSlowSearcher searcher(fsm); + searcher.Search("pref ala bla pref cla suff dla"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("pref ala bla pref cla suff")); - } - - Y_UNIT_TEST(SlowCapture2) { - TSlowCapturingFsm fsm("Здравствуйте, ((\\s|\\w|[()]|-)+)!", - TFsm::TOptions().SetCharset(CODES_UTF8)); - - TSlowSearcher searcher(fsm); - searcher.Search(" Здравствуйте, Уважаемый (-ая)! "); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(SlowCapture2) { + TSlowCapturingFsm fsm("Здравствуйте, ((\\s|\\w|[()]|-)+)!", + TFsm::TOptions().SetCharset(CODES_UTF8)); + + TSlowSearcher searcher(fsm); + searcher.Search(" Здравствуйте, Уважаемый (-ая)! "); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("Уважаемый (-ая)")); - } - - Y_UNIT_TEST(SlowCapture3) { - TSlowCapturingFsm fsm("here we have user_id=([a-z0-9]+);"); - TSlowSearcher searcher(fsm); - searcher.Search("in db and here we have user_id=0x0d0a; same as CRLF"); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(SlowCapture3) { + TSlowCapturingFsm fsm("here we have user_id=([a-z0-9]+);"); + TSlowSearcher searcher(fsm); + searcher.Search("in db and here we have user_id=0x0d0a; same as CRLF"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("0x0d0a")); - } - - Y_UNIT_TEST(SlowCapture4) { - TSlowCapturingFsm fsm("away\\.php\\?to=http:([^\"]+)\""); - TSlowSearcher searcher(fsm); - searcher.Search("\"/away.php?to=http:some.addr\"&id=1"); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(SlowCapture4) { + TSlowCapturingFsm fsm("away\\.php\\?to=http:([^\"]+)\""); + TSlowSearcher searcher(fsm); + searcher.Search("\"/away.php?to=http:some.addr\"&id=1"); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("some.addr")); - } - - Y_UNIT_TEST(CapturedEmptySlow) { - TSlowCapturingFsm fsm("Comments=(.*)$"); - TSlowSearcher searcher(fsm); - searcher.Search("And Comments="); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(CapturedEmptySlow) { + TSlowCapturingFsm fsm("Comments=(.*)$"); + TSlowSearcher searcher(fsm); + searcher.Search("And Comments="); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("")); - } - - Y_UNIT_TEST(CaptureInOrFirst) { - TSlowCapturingFsm fsm("(A)|A"); - TSlowSearcher searcher(fsm); - searcher.Search("A"); - UNIT_ASSERT(searcher.Captured()); - } - - Y_UNIT_TEST(CaptureInOrSecond) { - TSlowCapturingFsm fsm("A|(A)"); - TSlowSearcher searcher(fsm); - searcher.Search("A"); - UNIT_ASSERT(!searcher.Captured()); - } - - Y_UNIT_TEST(CaptureOutside) { - TSlowCapturingFsm fsm("((ID=([0-9]+))?)"); - TSlowSearcher searcher(fsm); - searcher.Search("ID="); - UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(CaptureInOrFirst) { + TSlowCapturingFsm fsm("(A)|A"); + TSlowSearcher searcher(fsm); + searcher.Search("A"); + UNIT_ASSERT(searcher.Captured()); + } + + Y_UNIT_TEST(CaptureInOrSecond) { + TSlowCapturingFsm fsm("A|(A)"); + TSlowSearcher searcher(fsm); + searcher.Search("A"); + UNIT_ASSERT(!searcher.Captured()); + } + + Y_UNIT_TEST(CaptureOutside) { + TSlowCapturingFsm fsm("((ID=([0-9]+))?)"); + TSlowSearcher searcher(fsm); + searcher.Search("ID="); + UNIT_ASSERT(searcher.Captured()); UNIT_ASSERT_VALUES_EQUAL(searcher.GetCaptured(), TStringBuf("")); - } - - Y_UNIT_TEST(CaptureInside) { - TSlowCapturingFsm fsm("((ID=([0-9]+))?)", - TFsm::TOptions().SetCapture(2)); - TSlowSearcher searcher(fsm); - searcher.Search("ID="); - UNIT_ASSERT(!searcher.Captured()); - } - + } + + Y_UNIT_TEST(CaptureInside) { + TSlowCapturingFsm fsm("((ID=([0-9]+))?)", + TFsm::TOptions().SetCapture(2)); + TSlowSearcher searcher(fsm); + searcher.Search("ID="); + UNIT_ASSERT(!searcher.Captured()); + } + Y_UNIT_TEST(Pcre2PireTest) { UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)"), "(fake)"); UNIT_ASSERT_VALUES_EQUAL(Pcre2Pire("(?:fake)??"), "(fake)?"); |