Skip to content

Commit ce1f1f1

Browse files
committed
Intermediate changes
1 parent 3ac0db1 commit ce1f1f1

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

util/string/strip_ut.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
2222
{"\n \t\r", "", "", ""},
2323
{"", "", "", ""},
2424
{"abc", "abc", "abc", "abc"},
25+
{" abc ", "abc ", " abc", "abc"},
2526
{"a c", "a c", "a c", "a c"},
2627
{" long string to avoid SSO \n", "long string to avoid SSO \n", " long string to avoid SSO", "long string to avoid SSO"},
28+
{" набор не-ascii букв ", "набор не-ascii букв ", " набор не-ascii букв", "набор не-ascii букв"},
29+
// Russian "х" ends with \x85, whis is a space character in some encodings.
30+
{"последней буквой идет х ", "последней буквой идет х ", "последней буквой идет х", "последней буквой идет х"},
2731
};
2832

2933
Y_UNIT_TEST(TestStrip) {
@@ -32,20 +36,23 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
3236

3337
TString s;
3438
Strip(inputStr, s);
35-
UNIT_ASSERT_EQUAL(s, test.StripRes);
39+
UNIT_ASSERT_VALUES_EQUAL(s, test.StripRes);
3640

37-
UNIT_ASSERT_EQUAL(StripString(inputStr), test.StripRes);
38-
UNIT_ASSERT_EQUAL(StripStringLeft(inputStr), test.StripLeftRes);
39-
UNIT_ASSERT_EQUAL(StripStringRight(inputStr), test.StripRightRes);
41+
UNIT_ASSERT_VALUES_EQUAL(StripString(inputStr), test.StripRes);
42+
UNIT_ASSERT_VALUES_EQUAL(StripStringLeft(inputStr), test.StripLeftRes);
43+
UNIT_ASSERT_VALUES_EQUAL(StripStringRight(inputStr), test.StripRightRes);
4044

4145
TStringBuf inputStrBuf(test.Str);
42-
UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes);
43-
UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
44-
UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes);
46+
UNIT_ASSERT_VALUES_EQUAL(StripString(inputStrBuf), test.StripRes);
47+
UNIT_ASSERT_VALUES_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
48+
UNIT_ASSERT_VALUES_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes);
4549
};
4650
}
4751

4852
Y_UNIT_TEST(TestStripInPlace) {
53+
// On Darwin default locale is set to a value which interprets certain cyrillic utf-8 sequences as spaces.
54+
// Which we do not use ::isspace and only strip ASCII spaces, we want to ensure that this will not change in the future.
55+
std::setlocale(LC_ALL, "");
4956
for (const auto& test : StripTests) {
5057
TString str(test.Str);
5158
Y_ASSERT(str.IsDetached() || str.empty()); // prerequisite of the test; check that we don't try to modify shared COW-string in-place by accident

0 commit comments

Comments
 (0)