mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-13358 No-data test fixes (cf. BRS task).
X-SVN-Rev: 40599
This commit is contained in:
parent
a86ba51982
commit
b96966a131
10 changed files with 43 additions and 17 deletions
|
@ -1954,7 +1954,10 @@ UnicodeString MessageFormat::PluralSelectorProvider::select(void *ctx, double nu
|
|||
context.formatter = msgFormat.getDefaultNumberFormat(ec);
|
||||
context.forReplaceNumber = TRUE;
|
||||
}
|
||||
U_ASSERT(context.number.getDouble(ec) == number); // argument number minus the offset
|
||||
if (context.number.getDouble(ec) != number) {
|
||||
ec = U_INTERNAL_PROGRAM_ERROR;
|
||||
return UnicodeString(FALSE, OTHER_STRING, 5);
|
||||
}
|
||||
context.formatter->format(context.number, context.numberString, ec);
|
||||
const DecimalFormat *decFmt = dynamic_cast<const DecimalFormat *>(context.formatter);
|
||||
if(decFmt != NULL) {
|
||||
|
|
|
@ -60,6 +60,7 @@ void CompactData::populate(const Locale &locale, const char *nsName, CompactStyl
|
|||
CompactType compactType, UErrorCode &status) {
|
||||
CompactDataSink sink(*this);
|
||||
LocalUResourceBundlePointer rb(ures_open(nullptr, locale.getName(), &status));
|
||||
if (U_FAILURE(status)) { return; }
|
||||
|
||||
bool nsIsLatn = strcmp(nsName, "latn") == 0;
|
||||
bool compactIsShort = compactStyle == CompactStyle::UNUM_SHORT;
|
||||
|
|
|
@ -321,20 +321,24 @@ LocalizedNumberFormatter::formatImpl(impl::NumberFormatterResults *results, UErr
|
|||
}
|
||||
|
||||
UnicodeString FormattedNumber::toString() const {
|
||||
if (fResults == nullptr) { return {}; }
|
||||
return fResults->string.toUnicodeString();
|
||||
}
|
||||
|
||||
Appendable &FormattedNumber::appendTo(Appendable &appendable) {
|
||||
if (fResults == nullptr) { return appendable; }
|
||||
appendable.appendString(fResults->string.chars(), fResults->string.length());
|
||||
return appendable;
|
||||
}
|
||||
|
||||
void FormattedNumber::populateFieldPosition(FieldPosition &fieldPosition, UErrorCode &status) {
|
||||
if (fResults == nullptr) { return; }
|
||||
fResults->string.populateFieldPosition(fieldPosition, 0, status);
|
||||
}
|
||||
|
||||
void
|
||||
FormattedNumber::populateFieldPositionIterator(FieldPositionIterator &iterator, UErrorCode &status) {
|
||||
if (fResults == nullptr) { return; }
|
||||
fResults->string.populateFieldPositionIterator(iterator, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ const char16_t *getPatternForStyle(const Locale &locale, const char *nsName, Cld
|
|||
break;
|
||||
}
|
||||
LocalUResourceBundlePointer res(ures_open(nullptr, locale.getName(), &status));
|
||||
if (U_FAILURE(status)) { return u""; }
|
||||
|
||||
// Attempt to get the pattern with the native numbering system.
|
||||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
|
@ -181,7 +182,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps ¯os, bool safe,
|
|||
// Give ownership to the function scope.
|
||||
nsLocal.adoptInstead(ns);
|
||||
}
|
||||
const char *nsName = ns->getName();
|
||||
const char *nsName = U_SUCCESS(status) ? ns->getName() : "latn";
|
||||
|
||||
// Load and parse the pattern string. It is used for grouping sizes and affixes only.
|
||||
CldrPatternStyle patternStyle;
|
||||
|
|
|
@ -43,7 +43,7 @@ NormalizerConformanceTest::NormalizerConformanceTest() :
|
|||
nfd = Normalizer2::getNFDInstance(errorCode);
|
||||
nfkc = Normalizer2::getNFKCInstance(errorCode);
|
||||
nfkd = Normalizer2::getNFKDInstance(errorCode);
|
||||
U_ASSERT(U_SUCCESS(errorCode));
|
||||
assertSuccess("", errorCode, true, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
NormalizerConformanceTest::~NormalizerConformanceTest() {}
|
||||
|
@ -368,19 +368,20 @@ UBool NormalizerConformanceTest::checkConformance(const UnicodeString* field,
|
|||
if(!Normalizer::isNormalized(field[3], UNORM_NFKC, options, status)) {
|
||||
dataerrln("Normalizer error: isNormalized(NFKC(s), UNORM_NFKC) is FALSE");
|
||||
pass = FALSE;
|
||||
}
|
||||
if(options==0 && !isNormalizedUTF8(*nfkc, field[3], status)) {
|
||||
dataerrln("Normalizer error: nfkc.isNormalizedUTF8(NFKC(s)) is FALSE");
|
||||
pass = FALSE;
|
||||
}
|
||||
if(field[0]!=field[3]) {
|
||||
if(Normalizer::isNormalized(field[0], UNORM_NFKC, options, status)) {
|
||||
errln("Normalizer error: isNormalized(s, UNORM_NFKC) is TRUE");
|
||||
} else {
|
||||
if(options==0 && !isNormalizedUTF8(*nfkc, field[3], status)) {
|
||||
dataerrln("Normalizer error: nfkc.isNormalizedUTF8(NFKC(s)) is FALSE");
|
||||
pass = FALSE;
|
||||
}
|
||||
if(options==0 && isNormalizedUTF8(*nfkc, field[0], status)) {
|
||||
errln("Normalizer error: nfkc.isNormalizedUTF8(s) is TRUE");
|
||||
pass = FALSE;
|
||||
if(field[0]!=field[3]) {
|
||||
if(Normalizer::isNormalized(field[0], UNORM_NFKC, options, status)) {
|
||||
errln("Normalizer error: isNormalized(s, UNORM_NFKC) is TRUE");
|
||||
pass = FALSE;
|
||||
}
|
||||
if(options==0 && isNormalizedUTF8(*nfkc, field[0], status)) {
|
||||
errln("Normalizer error: nfkc.isNormalizedUTF8(s) is TRUE");
|
||||
pass = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ UErrorCode globalNumberFormatterApiTestStatus = U_ZERO_ERROR;
|
|||
|
||||
NumberFormatterApiTest::NumberFormatterApiTest()
|
||||
: NumberFormatterApiTest(globalNumberFormatterApiTestStatus) {
|
||||
U_ASSERT(U_SUCCESS(globalNumberFormatterApiTestStatus));
|
||||
}
|
||||
|
||||
NumberFormatterApiTest::NumberFormatterApiTest(UErrorCode &status)
|
||||
|
@ -28,6 +27,10 @@ NumberFormatterApiTest::NumberFormatterApiTest(UErrorCode &status)
|
|||
MYANMAR_SYMBOLS(Locale("my"), status) {
|
||||
|
||||
MeasureUnit *unit = MeasureUnit::createMeter(status);
|
||||
if (U_FAILURE(status)) {
|
||||
dataerrln("%s %d status = %s", __FILE__, __LINE__, u_errorName(status));
|
||||
return;
|
||||
}
|
||||
METER = *unit;
|
||||
delete unit;
|
||||
unit = MeasureUnit::createDay(status);
|
||||
|
|
|
@ -79,6 +79,7 @@ void PatternModifierTest::testMutableEqualsImmutable() {
|
|||
DecimalFormatSymbols symbols(Locale::getEnglish(), status);
|
||||
CurrencyUnit currency(u"USD", status);
|
||||
assertSuccess("Spot 2", status);
|
||||
if (U_FAILURE(status)) { return; }
|
||||
mod.setSymbols(&symbols, currency, UNUM_UNIT_WIDTH_SHORT, nullptr);
|
||||
DecimalQuantity fq;
|
||||
fq.setToInt(1);
|
||||
|
|
|
@ -8810,8 +8810,12 @@ void NumberFormatTest::Test13327_numberingSystemBufferOverflow() {
|
|||
|
||||
void NumberFormatTest::Test13391_chakmaParsing() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocalPointer<DecimalFormat> df(static_cast<DecimalFormat*>(
|
||||
LocalPointer<DecimalFormat> df(dynamic_cast<DecimalFormat*>(
|
||||
NumberFormat::createInstance(Locale("ccp"), status)));
|
||||
if (df == nullptr) {
|
||||
dataerrln("%s %d Chakma df is null", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
const UChar* expected = u"\U00011137\U00011138,\U00011139\U0001113A\U0001113B";
|
||||
UnicodeString actual;
|
||||
df->format(12345, actual, status);
|
||||
|
|
|
@ -4818,8 +4818,12 @@ void RBBITest::TestBug12519() {
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocalPointer<RuleBasedBreakIterator> biEn((RuleBasedBreakIterator *)BreakIterator::createWordInstance(Locale::getEnglish(), status));
|
||||
LocalPointer<RuleBasedBreakIterator> biFr((RuleBasedBreakIterator *)BreakIterator::createWordInstance(Locale::getFrance(), status));
|
||||
assertSuccess(WHERE, status);
|
||||
if (!assertSuccess(WHERE, status)) {
|
||||
dataerrln("%s %d status = %s", __FILE__, __LINE__, u_errorName(status));
|
||||
return;
|
||||
}
|
||||
assertTrue(WHERE, Locale::getEnglish() == biEn->getLocale(ULOC_VALID_LOCALE, status));
|
||||
|
||||
assertTrue(WHERE, Locale::getFrench() == biFr->getLocale(ULOC_VALID_LOCALE, status));
|
||||
assertTrue(WHERE "Locales do not participate in BreakIterator equality.", *biEn == *biFr);
|
||||
|
||||
|
|
|
@ -1261,6 +1261,10 @@ void
|
|||
TimeZoneFormatTest::TestFormatTZDBNamesAllZoneCoverage(void) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocalPointer<StringEnumeration> tzids(TimeZone::createEnumeration());
|
||||
if (tzids.getAlias() == nullptr) {
|
||||
dataerrln("%s %d tzids is null", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
const UnicodeString *tzid;
|
||||
LocalPointer<TimeZoneNames> tzdbNames(TimeZoneNames::createTZDBInstance(Locale("en"), status));
|
||||
UDate now = Calendar::getNow();
|
||||
|
|
Loading…
Add table
Reference in a new issue