diff options
| author | levlam <levlam@telegram.org> | 2025-07-06 06:03:31 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-07-06 06:03:31 +0300 |
| commit | 566a1a8d4bd2cac6abd459f37fea3175b7581ed7 (patch) | |
| tree | b8e48ea84e2af92d043ba128aaf4c2e04b8557a1 /tdutils/test | |
| parent | 43192229ade978f4b251c5e740f8ba6a64dbd052 (diff) | |
Add test for replace_with_spaces.
Diffstat (limited to 'tdutils/test')
| -rw-r--r-- | tdutils/test/misc.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp index adede0cdc..6a3c2bd2a 100644 --- a/tdutils/test/misc.cpp +++ b/tdutils/test/misc.cpp @@ -942,6 +942,21 @@ TEST(Misc, full_split) { test_full_split("ab cd ef gh", ' ', 3, {"ab", "cd", "ef gh"}); } +static void test_replace_with_spaces(td::MutableSlice str, td::Slice characters, td::Slice expected) { + replace_with_spaces(str, characters); + ASSERT_EQ(expected, str); +} + +TEST(Misc, replace_with_spaces) { + td::string s("asd\nasd"); + test_replace_with_spaces(s, "", s); + test_replace_with_spaces(s, "bcef", s); + test_replace_with_spaces(s, "\n", "asd asd"); + test_replace_with_spaces(s, "as", " d d"); + test_replace_with_spaces(s, "as", " d d"); + test_replace_with_spaces(s, "asd", " "); +} + TEST(Misc, StringBuilder) { auto small_str = td::string{"abcdefghij"}; auto big_str = td::string(1000, 'a'); |
