unicode: add unit test for normalize
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
6d1d9bd1b8
commit
bb9988933e
@ -87,6 +87,18 @@ namespace UnitTests
|
||||
"",
|
||||
win1250_to_utf8.convert(nullptr, 0).c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(normalize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Assert::AreEqual(
|
||||
L"tést",
|
||||
stdex::normalize(L"tést").c_str());
|
||||
Assert::AreEqual(
|
||||
L"",
|
||||
stdex::normalize(nullptr, 0).c_str());
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -818,10 +818,12 @@ namespace stdex
|
||||
size_t count_dst = dst.size();
|
||||
dst.resize(count_dst + count_src);
|
||||
_Assume_(count_src + 1 < INT_MAX);
|
||||
#pragma warning(suppress: 6387) // Testing indicates src may be NULL when count_src is also 0. Is SAL of the lpSrcString parameter wrong?
|
||||
int r = NormalizeString(NormalizationC, src, static_cast<int>(count_src), dst.data() + count_dst, static_cast<int>(count_src + 1));
|
||||
if (r >= 0)
|
||||
dst.resize(count_dst + r);
|
||||
else
|
||||
#pragma warning(suppress: 6387) // Testing indicates src may be NULL when count_src is also 0. Is SAL of the _Src parameter wrong?
|
||||
memcpy(dst.data() + count_dst, src, count_src * sizeof(wchar_t));
|
||||
return dst.size();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user