From fa67b45f50359417cc5fe960551ec08d594c67da Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 21 Sep 2022 15:52:26 +0400 Subject: [PATCH] Got rid of unused *pendToFirstOccurence() funcs --- src/tools/regexTools.cpp | 38 -------------------------------------- src/tools/regexTools.h | 6 ------ test/regex.cpp | 27 --------------------------- 3 files changed, 71 deletions(-) diff --git a/src/tools/regexTools.cpp b/src/tools/regexTools.cpp index 36305cbbc..472dd4199 100644 --- a/src/tools/regexTools.cpp +++ b/src/tools/regexTools.cpp @@ -75,41 +75,3 @@ std::string replaceRegex(const std::string& content, uresult.toUTF8String(tmp); return tmp; } - -std::string appendToFirstOccurence(const std::string& content, - const std::string& regex, - const std::string& replacement) -{ - ucnv_setDefaultName("UTF-8"); - icu::UnicodeString ucontent(content.c_str()); - icu::UnicodeString ureplacement(replacement.c_str()); - auto matcher = buildMatcher(regex, ucontent); - if (matcher->find()) { - UErrorCode status = U_ZERO_ERROR; - ucontent.insert(matcher->end(status), ureplacement); - std::string tmp; - ucontent.toUTF8String(tmp); - return tmp; - } - - return content; -} - -std::string prependToFirstOccurence(const std::string& content, - const std::string& regex, - const std::string& replacement) -{ - ucnv_setDefaultName("UTF-8"); - icu::UnicodeString ucontent(content.c_str()); - icu::UnicodeString ureplacement(replacement.c_str()); - auto matcher = buildMatcher(regex, ucontent); - if (matcher->find()) { - UErrorCode status = U_ZERO_ERROR; - ucontent.insert(matcher->start(status), ureplacement); - std::string tmp; - ucontent.toUTF8String(tmp); - return tmp; - } - - return content; -} diff --git a/src/tools/regexTools.h b/src/tools/regexTools.h index 50ce28647..e4c61a43c 100644 --- a/src/tools/regexTools.h +++ b/src/tools/regexTools.h @@ -26,11 +26,5 @@ bool matchRegex(const std::string& content, const std::string& regex); std::string replaceRegex(const std::string& content, const std::string& replacement, const std::string& regex); -std::string appendToFirstOccurence(const std::string& content, - const std::string& regex, - const std::string& replacement); -std::string prependToFirstOccurence(const std::string& content, - const std::string& regex, - const std::string& replacement); #endif diff --git a/test/regex.cpp b/test/regex.cpp index 0d83055b0..e9d00cd6b 100644 --- a/test/regex.cpp +++ b/test/regex.cpp @@ -73,31 +73,4 @@ TEST(ReplaceRegex, middle) EXPECT_EQ(replaceRegex("abcdefghij", "----", "F"), "abcde----ghij"); } -TEST(append, beggining) -{ - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "abcd", "----"), "abcd----efghij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "abcde", "----"), "abcde----fghij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "a.*i", "----"), "abcdefghi----j"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "AbCd", "----"), "abcd----efghij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "A", "----"), "a----bcdefghij"); -} - -TEST(append, end) -{ - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "ghij", "----"), "abcdefghij----"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "fghij", "----"), "abcdefghij----"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "c.*j", "----"), "abcdefghij----"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "GhIj", "----"), "abcdefghij----"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "J", "----"), "abcdefghij----"); -} - -TEST(append, middle) -{ - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "cdef", "----"), "abcdef----ghij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "cdefgh", "----"), "abcdefgh----ij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "c.*f", "----"), "abcdef----ghij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "DeFg", "----"), "abcdefg----hij"); - EXPECT_EQ(appendToFirstOccurence("abcdefghij", "F", "----"), "abcdef----ghij"); -} - };