MCPcopy Create free account
hub / github.com/catboost/catboost / TestToLowerStr

Method TestToLowerStr

util/charset/wide_ut.cpp:1133–1363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1131 }
1132
1133 void TestToLowerStr() {
1134 // In these test and test for `ToUpper` and `ToTitle` we are checking that string keep
1135 // pointing to the same piece of memory we are doing it the following way:
1136 //
1137 // TUtf16String s = ...
1138 // const auto copy = s;
1139 // ...
1140 // UNIT_ASSERT(s.data() == copy.data())
1141 //
1142 // It saves us a couple lines (we are reusing `copy` later) and if one day `TString` will
1143 // become non-refcounted we'll need to rewrite it to something like:
1144 //
1145 // TUtf16String s = ...
1146 // const auto* const data = s.data();
1147 // const auto length = s.length();
1148 // ...
1149 // UNIT_ASSERT(s.data() == data);
1150 // UNIT_ASSERT(s.length() == length);
1151 {
1152 TUtf16String s;
1153 auto writableCopy = s;
1154 const auto copy = s;
1155 const TUtf16String lower;
1156
1157 UNIT_ASSERT(!ToLower(s));
1158 UNIT_ASSERT(s == lower);
1159#ifndef TSTRING_IS_STD_STRING
1160 UNIT_ASSERT(s.data() == copy.data());
1161#endif
1162
1163 UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
1164 UNIT_ASSERT(writableCopy == lower);
1165
1166 UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
1167 UNIT_ASSERT(writableCopy == lower);
1168
1169 UNIT_ASSERT(ToLowerRet(copy) == lower);
1170 UNIT_ASSERT(ToLowerRet(TWtringBuf(copy)) == lower);
1171 }
1172 {
1173 TUtf16String s = UTF8ToWide("");
1174 auto writableCopy = s;
1175 const auto copy = s;
1176 const TUtf16String lower;
1177
1178 UNIT_ASSERT(!ToLower(s));
1179 UNIT_ASSERT(s == lower);
1180#ifndef TSTRING_IS_STD_STRING
1181 UNIT_ASSERT(s.data() == copy.data());
1182#endif
1183
1184 UNIT_ASSERT(!ToLower(writableCopy.Detach(), writableCopy.size()));
1185 UNIT_ASSERT(writableCopy == lower);
1186
1187 UNIT_ASSERT(!ToLower(copy.data(), copy.size(), writableCopy.Detach()));
1188 UNIT_ASSERT(writableCopy == lower);
1189
1190 UNIT_ASSERT(ToLowerRet(copy) == lower);

Callers

nothing calls this directly

Calls 6

ToLowerRetFunction · 0.85
ToLowerFunction · 0.70
UTF8ToWideFunction · 0.70
dataMethod · 0.45
DetachMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected