From 59703521ae0514bce9782ef58e11e9e9175ea42e Mon Sep 17 00:00:00 2001 From: sherlock2010 <15151851377@163.com> Date: Wed, 14 Dec 2022 11:05:55 +0000 Subject: [PATCH] add some testcases for abnormal branches (cherry picked from commit 57a4d27bd9240a01bbb00756302c52bd245be5d0) --- ...some-testcases-for-abnormal-branches.patch | 42 +++++++++++++++++++ re2.spec | 6 ++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 add-some-testcases-for-abnormal-branches.patch diff --git a/add-some-testcases-for-abnormal-branches.patch b/add-some-testcases-for-abnormal-branches.patch new file mode 100644 index 0000000..3a3dab7 --- /dev/null +++ b/add-some-testcases-for-abnormal-branches.patch @@ -0,0 +1,42 @@ +From 1e89b6846a1a2597a7e9c4ad23842e6be534b87e Mon Sep 17 00:00:00 2001 +From: zhouyh +Date: Wed, 14 Dec 2022 18:42:49 +0800 +Subject: [PATCH] add some testcases for abnormal branches + +--- + re2/testing/re2_test.cc | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc +index b1f7d73..51a1739 100644 +--- a/re2/testing/re2_test.cc ++++ b/re2/testing/re2_test.cc +@@ -211,6 +211,16 @@ TEST(CheckRewriteString, all) { + TestCheckRewriteString("a(b)(c)", "f\\oo\\1", false); + } + ++TEST(RE2, Rewrite) { ++ RE2 re("(foo)|(bar)baz"); ++ StringPiece group[4]; ++ std::string out; ++ ++ ASSERT_FALSE(re.Rewrite(&out, "hello\\5", group, arraysize(group))); ++ ASSERT_FALSE(re.Rewrite(&out,"hello\\a", group, arraysize(group))); ++ ASSERT_TRUE(re.Rewrite(&out,"hello\\\\", group, arraysize(group))); ++} ++ + TEST(RE2, Extract) { + std::string s; + +@@ -360,6 +370,8 @@ TEST(RE2, Match) { + ASSERT_EQ(group[1], "chrisr:9000"); + ASSERT_EQ(group[2], "chrisr"); + ASSERT_EQ(group[3], "9000"); ++ ASSERT_FALSE( ++ re.Match(s, 2, 1, RE2::UNANCHORED, group, arraysize(group))); + + std::string all, host; + int port; +-- +2.33.0 + diff --git a/re2.spec b/re2.spec index 5745581..268b60e 100644 --- a/re2.spec +++ b/re2.spec @@ -1,11 +1,12 @@ Name: re2 Version: 20211101 -Release: 2 +Release: 3 Summary: Provide backtracking RE engine License: BSD URL: http://github.com/google/re2/ Source0: https://github.com/google/re2/archive/2021-11-01.tar.gz Patch0: backport-fix-64-to-32-bit-clang-conversion-warning.patch +Patch1: add-some-testcases-for-abnormal-branches.patch BuildRequires: gcc-c++ %description @@ -50,6 +51,9 @@ make %{?_smp_mflags} shared-test %exclude %{_libdir}/libre2.a %changelog +* Wed Dec 14 2022 zhouyihang - 20211101-3 +- add some testcases for abnormal branches + * Mon Oct 24 2022 gaihuiying - 20211101-2 - fix 64 to 32 bit clang conversion warning -- Gitee