diff options
author | qkrorlqr <qkrorlqr@yandex-team.ru> | 2022-02-10 16:47:20 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:20 +0300 |
commit | 9b89266638b10d40309e31dcb7caa2fc52b2aefd (patch) | |
tree | aaf0d6ece270940a4f208e4202e4a37a15ce05b7 /library/cpp/regex/pcre | |
parent | 47af3b5bf148ddab250833ec454d30d7c4930c31 (diff) | |
download | ydb-9b89266638b10d40309e31dcb7caa2fc52b2aefd.tar.gz |
Restoring authorship annotation for <qkrorlqr@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/regex/pcre')
-rw-r--r-- | library/cpp/regex/pcre/regexp.cpp | 4 | ||||
-rw-r--r-- | library/cpp/regex/pcre/regexp.h | 2 | ||||
-rw-r--r-- | library/cpp/regex/pcre/regexp_ut.cpp | 60 |
3 files changed, 33 insertions, 33 deletions
diff --git a/library/cpp/regex/pcre/regexp.cpp b/library/cpp/regex/pcre/regexp.cpp index 575c09cee4..c0474e9f39 100644 --- a/library/cpp/regex/pcre/regexp.cpp +++ b/library/cpp/regex/pcre/regexp.cpp @@ -2,7 +2,7 @@ #include <util/generic/string.h> #include <util/string/ascii.h> -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <cstdlib> #include <util/generic/noncopyable.h> @@ -218,7 +218,7 @@ int TRegExBase::Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatc return Impl->Exec(str, pmatch, eflags, nmatches); } -int TRegExBase::GetCompileOptions() const { +int TRegExBase::GetCompileOptions() const { if (!Impl) ythrow yexception() << "!Regular expression is not compiled"; return Impl->CompileOptions; diff --git a/library/cpp/regex/pcre/regexp.h b/library/cpp/regex/pcre/regexp.h index bc610bd2f3..12c85ed58b 100644 --- a/library/cpp/regex/pcre/regexp.h +++ b/library/cpp/regex/pcre/regexp.h @@ -29,7 +29,7 @@ public: int Exec(const char* str, regmatch_t pmatch[], int eflags, int nmatches = NMATCHES) const; void Compile(const TString& regExpr, int cflags = REG_EXTENDED); bool IsCompiled() const; - int GetCompileOptions() const; + int GetCompileOptions() const; TString GetRegExpr() const; }; diff --git a/library/cpp/regex/pcre/regexp_ut.cpp b/library/cpp/regex/pcre/regexp_ut.cpp index 5184e801cc..91ea95d040 100644 --- a/library/cpp/regex/pcre/regexp_ut.cpp +++ b/library/cpp/regex/pcre/regexp_ut.cpp @@ -22,26 +22,26 @@ struct TRegTest { }; struct TSubstTest: public TRegTest { - const char* Replacement; - const char* Replacement2; - - TSubstTest(const char* re, const char* text, const char* res, const char* repl, const char* repl2) - : TRegTest(re, text, res, REG_EXTENDED, REGEXP_GLOBAL) - , Replacement(repl) - , Replacement2(repl2) + const char* Replacement; + const char* Replacement2; + + TSubstTest(const char* re, const char* text, const char* res, const char* repl, const char* repl2) + : TRegTest(re, text, res, REG_EXTENDED, REGEXP_GLOBAL) + , Replacement(repl) + , Replacement2(repl2) { } -}; - +}; + const TRegTest REGTEST_DATA[] = { TRegTest("test", "its a test and test string.", "6 10", REG_EXTENDED, 0), TRegTest("test", "its a test and test string.", "6 10 15 19", REG_EXTENDED, REGEXP_GLOBAL), TRegTest("test|[an]{0,0}", "test and test an test string tes", "0 4 4 4 5 5 6 6 7 7 8 8 9 13 13 13 14 14 15 15 16 16 17 21 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32", REG_EXTENDED, REGEXP_GLOBAL), TRegTest("test[an]{1,}", "test and test an test string tes", "NM", REG_EXTENDED, REGEXP_GLOBAL)}; -const TSubstTest SUBSTTEST_DATA[] = { - TSubstTest("([a-zA-Z]*[0-9]+) (_[a-z]+)", "Xxx123 534 ___124 bsd _A ZXC _L 141 _sd dsfg QWE123 _bbb", "141 XXX/_sd", "$1 XXX/$2", "$2$2$2 YY$1Y/$2")}; - +const TSubstTest SUBSTTEST_DATA[] = { + TSubstTest("([a-zA-Z]*[0-9]+) (_[a-z]+)", "Xxx123 534 ___124 bsd _A ZXC _L 141 _sd dsfg QWE123 _bbb", "141 XXX/_sd", "$1 XXX/$2", "$2$2$2 YY$1Y/$2")}; + class TRegexpTest: public TTestBase { private: regmatch_t Matches[NMATCHES]; @@ -49,7 +49,7 @@ private: private: UNIT_TEST_SUITE(TRegexpTest); UNIT_TEST(TestRe) - UNIT_TEST(TestSubst) + UNIT_TEST(TestSubst) UNIT_TEST(TestOffEndOfBuffer); UNIT_TEST_SUITE_END(); @@ -58,8 +58,8 @@ private: memset(Matches, 0, sizeof(Matches)); TString result; - TRegExBase re(regTest.Regexp, regTest.CompileOptions); - if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { + TRegExBase re(regTest.Regexp, regTest.CompileOptions); + if (re.Exec(regTest.Data, Matches, regTest.RunOptions) == 0) { for (auto& matche : Matches) { if (matche.rm_so == -1) { break; @@ -70,27 +70,27 @@ private: result = "NM"; } StripInPlace(result); - UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); + UNIT_ASSERT_VALUES_EQUAL(result, regTest.Result); } } - - inline void TestSubst() { + + inline void TestSubst() { for (const auto& substTest : SUBSTTEST_DATA) { - TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); - subst.ParseReplacement(substTest.Replacement); + TRegExSubst subst(substTest.Regexp, substTest.CompileOptions); + subst.ParseReplacement(substTest.Replacement); TString result = subst.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(result, substTest.Result); - TRegExSubst substCopy = subst; - subst.ParseReplacement(substTest.Replacement2); + UNIT_ASSERT_VALUES_EQUAL(result, substTest.Result); + TRegExSubst substCopy = subst; + subst.ParseReplacement(substTest.Replacement2); TString newResult = subst.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_UNEQUAL(newResult.c_str(), result.c_str()); + UNIT_ASSERT_VALUES_UNEQUAL(newResult.c_str(), result.c_str()); TString copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(copyResult, result); - substCopy = subst; - copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); - UNIT_ASSERT_VALUES_EQUAL(copyResult, newResult); - } - } + UNIT_ASSERT_VALUES_EQUAL(copyResult, result); + substCopy = subst; + copyResult = substCopy.Replace(substTest.Data, substTest.RunOptions); + UNIT_ASSERT_VALUES_EQUAL(copyResult, newResult); + } + } void TestOffEndOfBuffer() { const TString needle{".*[^./]gov[.].*"}; |