ICU-12663 TestLongUpper() exit early if out of memory

X-SVN-Rev: 39300
This commit is contained in:
Markus Scherer 2016-09-20 21:42:28 +00:00
parent 7827611586
commit 5afeb0ae2f

View File

@ -698,8 +698,12 @@ StringCaseTest::TestLongUpper() {
int32_t length = 0x40000004; // more than 1G UChars
UnicodeString s(length, (UChar32)0x390, length);
UnicodeString result;
IcuTestErrorCode errorCode(*this, "TestLongUpper");
UChar *dest = result.getBuffer(length + 1);
if (s.isBogus() || dest == NULL) {
logln("Out of memory, unable to run this test on this machine.");
return;
}
IcuTestErrorCode errorCode(*this, "TestLongUpper");
int32_t destLength = u_strToUpper(dest, result.getCapacity(),
s.getBuffer(), s.length(), "", errorCode);
result.releaseBuffer(destLength);