124 Star 0 Fork 10

src-openEuler/re2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add-some-testcases-for-abnormal-branches.patch 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
From 1e89b6846a1a2597a7e9c4ad23842e6be534b87e Mon Sep 17 00:00:00 2001
From: zhouyh <zhouyihang3@h-partners.com>
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/re2.git
git@gitee.com:src-openeuler/re2.git
src-openeuler
re2
re2
master

搜索帮助