From dfe36e15a5657b274c20cda3f00f03209a07c3ca Mon Sep 17 00:00:00 2001 From: mengning997 Date: Thu, 15 Sep 2022 16:01:36 +0800 Subject: [PATCH] fixed three tests --- re2/re2.cc | 4 ++-- re2/testing/re2_test.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/re2/re2.cc b/re2/re2.cc index e67b5aa..3881e36 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -188,7 +188,7 @@ namespace re2 rure_error *err = rure_error_new(); // 对传入的Latin-1编码的字符串要进行转换 - if (options.encoding() == 1) + if (options.encoding() == re2::RE2::Options::EncodingUTF8) { // UTF-8编码 rure_str = pattern.ToString(); } @@ -947,7 +947,7 @@ namespace re2 return true; } // for FullMatch(no captures) - if(re_anchor == ANCHOR_BOTH && n == 0) + if(re_anchor == ANCHOR_BOTH && n == 0 && options_.encoding() == re2::RE2::Options::EncodingUTF8) { bool matched = rure_is_match((rure *)entire_regexp_, (const uint8_t *)text.data(), (size_t)text.size(), 0); return matched; diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index 0ae12c4..6d3ba11 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -434,7 +434,7 @@ TEST(QuoteMeta, SimpleNegative) { } TEST(QuoteMeta, Latin1) { - // TestQuoteMeta("3\xb2 = 9", RE2::Latin1); + TestQuoteMeta("3\xb2 = 9", RE2::Latin1); } TEST(QuoteMeta, UTF8) { @@ -1107,7 +1107,7 @@ TEST(RE2, UTF8) { // Both should match in either mode, bytes or UTF-8 RE2 re_test1(".........", RE2::Latin1); - // ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test1)); + ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test1)); RE2 re_test2("..."); ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test2)); @@ -1125,7 +1125,7 @@ TEST(RE2, UTF8) { // Check that string matches itself in either mode RE2 re_test5(utf8_string, RE2::Latin1); - // ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test5)); + ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test5)); RE2 re_test6(utf8_string); ASSERT_TRUE(RE2::FullMatch(utf8_string, re_test6)); -- Gitee