summaryrefslogtreecommitdiffstats
path: root/util/string/strip_ut.cpp
diff options
context:
space:
mode:
authorOleg Sidorkin <[email protected]>2022-04-16 13:43:06 +0300
committerOleg Sidorkin <[email protected]>2022-04-16 13:43:06 +0300
commitc1e51b5d64d252145765d1529a71271ee4d33812 (patch)
treeaee1d5a24b2035a857fdf47ac4788b2278a088f5 /util/string/strip_ut.cpp
parent09be10fcbbf04de7c78405d5bf7c18117a1b339f (diff)
Add Collapse variant for utf-32 strings
ref:5897581c4d2be8d8775525221d2d910c04d788b8
Diffstat (limited to 'util/string/strip_ut.cpp')
-rw-r--r--util/string/strip_ut.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index d1029d1498a..df4f9bc57d3 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -107,6 +107,23 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
u"abc");
}
+ Y_UNIT_TEST(TestCollapseUtf32) {
+ TUtf32String s;
+ Collapse(UTF8ToUTF32<true>(" 123 456 "), s, IsWhitespace);
+ UNIT_ASSERT(s == UTF8ToUTF32<true>(" 123 456 "));
+ Collapse(UTF8ToUTF32<true>(" 123 456 "), s, IsWhitespace, 10);
+ UNIT_ASSERT(s == UTF8ToUTF32<true>(" 123 456 "));
+
+ s = UTF8ToUTF32<true>(" a b c ");
+ TUtf32String s2 = s;
+ CollapseInPlace(s2, IsWhitespace);
+
+ UNIT_ASSERT(s == s2);
+#ifndef TSTRING_IS_STD_STRING
+ UNIT_ASSERT(s.c_str() == s2.c_str()); // Collapse() does not change the string at all
+#endif
+ }
+
Y_UNIT_TEST(TestCollapse) {
TString s;
Collapse(TString(" 123 456 "), s);