check was needed in the test cases to prevent a segmentation fault.
delete cal;
cal = Calendar::createInstance(Locale("th_TH@calendar=buddhist"),status);
+ if(U_FAILURE(status)) {
+ dataerrln("Error creating calendar %s", u_errorName(status));
+ delete cal;
+ return;
+ }
// test deprecated functions
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
cal->getMaximum(Calendar::HOUR) != 11) {
delete cal;
// test deprecated functions
cal = Calendar::createInstance(Locale("ja_JP@calendar=japanese"),status);
+ if(U_FAILURE(status)) {
+ dataerrln("Error creating calendar %s", u_errorName(status));
+ delete cal;
+ return;
+ }
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
cal->getMaximum(Calendar::HOUR) != 11) {
errln("Fail: Japanese:[deprecated functions] maximum of HOUR field should be 11\n");
status.errIfFailureAndReset("key #1");
assertEquals("resultLength", 2, resultLength);
assertTrue("key != nullptr", key != nullptr);
- assertEquals("calendar", "ca", key);
+ if (key != nullptr) {
+ assertEquals("calendar", "ca", key);
+ }
key = keys->next(&resultLength, status);
status.errIfFailureAndReset("key #2");
assertEquals("resultLength", 2, resultLength);
assertTrue("key != nullptr", key != nullptr);
- assertEquals("collation", "co", key);
+ if (key != nullptr) {
+ assertEquals("collation", "co", key);
+ }
key = keys->next(&resultLength, status);
status.errIfFailureAndReset("end of keys");
skey = keys->snext(status);
status.errIfFailureAndReset("skey #1");
assertTrue("skey != nullptr", skey != nullptr);
- assertEquals("calendar", "ca", *skey);
+ if (skey != nullptr) {
+ assertEquals("calendar", "ca", *skey);
+ }
skey = keys->snext(status);
status.errIfFailureAndReset("skey #2");
assertTrue("skey != nullptr", skey != nullptr);
- assertEquals("collation", "co", *skey);
+ if (skey != nullptr) {
+ assertEquals("collation", "co", *skey);
+ }
skey = keys->snext(status);
status.errIfFailureAndReset("end of keys");
IcuTestErrorCode status(*this, "Test20073_StrictPercentParseErrorIndex");
ParsePosition parsePosition(0);
DecimalFormat df(u"0%", {"en-us", status}, status);
+ if (U_FAILURE(status)) {
+ dataerrln("Unable to create DecimalFormat instance.");
+ return;
+ }
df.setLenient(FALSE);
Formattable result;
df.parse(u"%2%", result, parsePosition);
IcuTestErrorCode status(*this, "Test20037_ScientificIntegerOverflow");
LocalPointer<NumberFormat> nf(NumberFormat::createInstance(status));
+ if (U_FAILURE(status)) {
+ dataerrln("Unable to create NumberFormat instance.");
+ return;
+ }
Formattable result;
// Test overflow of exponent
nf->parse(u"1E-2147483648", result, status);
StringPiece sp = result.getDecimalNumber(status);
assertEquals(u"Should snap to zero",
- u"0",
- {sp.data(), sp.length(), US_INV});
+ u"0",
+ {sp.data(), sp.length(), US_INV});
// Test edge case overflow of exponent
result = Formattable();
nf->parse(u"1E-2147483647E-1", result, status);
sp = result.getDecimalNumber(status);
assertEquals(u"Should not overflow and should parse only the first exponent",
- u"1E-2147483647",
- {sp.data(), sp.length(), US_INV});
+ u"1E-2147483647",
+ {sp.data(), sp.length(), US_INV});
}
void NumberFormatTest::Test13840_ParseLongStringCrash() {