diff --git a/doc/src/string/op.dox b/doc/src/string/op.dox index 561d45b..fd7a93d 100644 --- a/doc/src/string/op.dox +++ b/doc/src/string/op.dox @@ -37,7 +37,7 @@ yycc::string::op provide 2 functions for programmer do string replacement: \code void replace(std::u8string& strl, const std::u8string_view& from_strl, const std::u8string_view& to_strl); -std::u8string replace(const std::u8string_view& strl, const std::u8string_view& from_strl, const std::u8string_view& to_strl); +std::u8string to_replace(const std::u8string_view& strl, const std::u8string_view& from_strl, const std::u8string_view& to_strl); \endcode The first overload will do replacement in given string container directly. diff --git a/src/yycc/string/op.cpp b/src/yycc/string/op.cpp index ec192cf..9fda974 100644 --- a/src/yycc/string/op.cpp +++ b/src/yycc/string/op.cpp @@ -97,7 +97,7 @@ namespace yycc::string::op { } } - std::u8string replace(const std::u8string_view& _strl, const std::u8string_view& _from_strl, const std::u8string_view& _to_strl) { + std::u8string to_replace(const std::u8string_view& _strl, const std::u8string_view& _from_strl, const std::u8string_view& _to_strl) { // prepare result std::u8string strl(_strl); replace(strl, _from_strl, _to_strl); diff --git a/src/yycc/string/op.hpp b/src/yycc/string/op.hpp index 5ad1eef..da4b243 100644 --- a/src/yycc/string/op.hpp +++ b/src/yycc/string/op.hpp @@ -66,7 +66,7 @@ namespace yycc::string::op { * @param[in] _to_strl The \e new string. * @return The result of replacement. */ - std::u8string replace(const std::u8string_view& _strl, const std::u8string_view& _from_strl, const std::u8string_view& _to_strl); + std::u8string to_replace(const std::u8string_view& _strl, const std::u8string_view& _from_strl, const std::u8string_view& _to_strl); #pragma endregion diff --git a/test/yycc/string/op.cpp b/test/yycc/string/op.cpp index 7bc2151..169c2da 100644 --- a/test/yycc/string/op.cpp +++ b/test/yycc/string/op.cpp @@ -25,32 +25,32 @@ namespace yycctest::string::op { TEST(StringOp, Replace) { // Normal case { - auto rv = OP::replace(u8"aabbcc", u8"bb", u8"dd"); + auto rv = OP::to_replace(u8"aabbcc", u8"bb", u8"dd"); EXPECT_EQ(rv, u8"aaddcc"); } // No matched expected string { - auto rv = OP::replace(u8"aabbcc", u8"zz", u8"yy"); + auto rv = OP::to_replace(u8"aabbcc", u8"zz", u8"yy"); EXPECT_EQ(rv, u8"aabbcc"); } // Empty expected string { - auto rv = OP::replace(u8"aabbcc", std::u8string_view(), u8"zz"); + auto rv = OP::to_replace(u8"aabbcc", std::u8string_view(), u8"zz"); EXPECT_EQ(rv, u8"aabbcc"); } // Empty replace string { - auto rv = OP::replace(u8"aaaabbaa", u8"aa", u8""); + auto rv = OP::to_replace(u8"aaaabbaa", u8"aa", u8""); EXPECT_EQ(rv, u8"bb"); } // Nested replacing { - auto rv = OP::replace(u8"aaxcc", u8"x", u8"yx"); + auto rv = OP::to_replace(u8"aaxcc", u8"x", u8"yx"); EXPECT_EQ(rv, u8"aayxcc"); } // Empty source string { - auto rv = OP::replace(std::u8string_view(), u8"", u8"xy"); + auto rv = OP::to_replace(std::u8string_view(), u8"", u8"xy"); EXPECT_EQ(rv, u8""); } }