mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-10992 Ensure ICU4C 54 test suite passes without data
X-SVN-Rev: 36516
This commit is contained in:
parent
73c9cfdcb4
commit
7e3befc1a6
14 changed files with 217 additions and 195 deletions
|
@ -1476,21 +1476,24 @@ void TestGetLocale() {
|
|||
|
||||
/* collator instantiated from rules should have all three locales NULL */
|
||||
coll = ucol_openRules(rlz, rlzLen, UCOL_DEFAULT, UCOL_DEFAULT, NULL, &status);
|
||||
locale = ucol_getLocaleByType(coll, ULOC_REQUESTED_LOCALE, &status);
|
||||
if(U_SUCCESS(status) && locale != NULL) {
|
||||
log_err("For collator instantiated from rules, requested locale returned %s instead of NULL\n", locale);
|
||||
if (coll != NULL) {
|
||||
locale = ucol_getLocaleByType(coll, ULOC_REQUESTED_LOCALE, &status);
|
||||
if(U_SUCCESS(status) && locale != NULL) {
|
||||
log_err("For collator instantiated from rules, requested locale returned %s instead of NULL\n", locale);
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
locale = ucol_getLocaleByType(coll, ULOC_VALID_LOCALE, &status);
|
||||
if(locale != NULL) {
|
||||
log_err("For collator instantiated from rules, valid locale returned %s instead of NULL\n", locale);
|
||||
}
|
||||
locale = ucol_getLocaleByType(coll, ULOC_ACTUAL_LOCALE, &status);
|
||||
if(locale != NULL) {
|
||||
log_err("For collator instantiated from rules, actual locale returned %s instead of NULL\n", locale);
|
||||
}
|
||||
ucol_close(coll);
|
||||
} else {
|
||||
log_data_err("Couldn't get collator from ucol_openRules() - %s\n", u_errorName(status));
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
locale = ucol_getLocaleByType(coll, ULOC_VALID_LOCALE, &status);
|
||||
if(locale != NULL) {
|
||||
log_err("For collator instantiated from rules, valid locale returned %s instead of NULL\n", locale);
|
||||
}
|
||||
locale = ucol_getLocaleByType(coll, ULOC_ACTUAL_LOCALE, &status);
|
||||
if(locale != NULL) {
|
||||
log_err("For collator instantiated from rules, actual locale returned %s instead of NULL\n", locale);
|
||||
}
|
||||
ucol_close(coll);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1587,16 +1587,19 @@ static void TestOverrideNumberFormat(void) {
|
|||
int32_t i;
|
||||
unsigned j;
|
||||
|
||||
fmt=udat_open(UDAT_PATTERN, UDAT_PATTERN,"en_US",NULL,0,pattern, u_strlen(pattern), &status);
|
||||
if (!assertSuccess("udat_open()", &status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
overrideFmt = unum_open(UNUM_DEFAULT, NULL, 0, localeString, NULL, &status);
|
||||
assertSuccess("unum_open()", &status);
|
||||
|
||||
expected=(UChar*)malloc(sizeof(UChar) * 10);
|
||||
fields=(UChar*)malloc(sizeof(UChar) * 10);
|
||||
u_uastrcpy(fields, "d");
|
||||
u_uastrcpy(pattern,"MM d");
|
||||
|
||||
fmt=udat_open(UDAT_PATTERN, UDAT_PATTERN,"en_US",NULL,0,pattern, u_strlen(pattern), &status);
|
||||
assertSuccess("udat_open()", &status);
|
||||
|
||||
overrideFmt = unum_open(UNUM_DEFAULT, NULL, 0, localeString, NULL, &status);
|
||||
assertSuccess("unum_open()", &status);
|
||||
|
||||
// loop 50 times to check getter/setter
|
||||
for (i = 0; i < 50; i++){
|
||||
|
|
|
@ -5852,7 +5852,7 @@ static void TestForLanguageTag(void) {
|
|||
langtag_to_locale[i].bcpID, u_errorName(status));
|
||||
} else {
|
||||
if (uprv_strcmp(langtag_to_locale[i].locID, locale) != 0) {
|
||||
log_err("uloc_forLanguageTag returned locale [%s] for input language tag [%s] - expected: [%s]\n",
|
||||
log_data_err("uloc_forLanguageTag returned locale [%s] for input language tag [%s] - expected: [%s]\n",
|
||||
locale, langtag_to_locale[i].bcpID, langtag_to_locale[i].locID);
|
||||
}
|
||||
if (parsedLen != expParsedLen) {
|
||||
|
@ -5888,7 +5888,7 @@ static void TestToUnicodeLocaleKey(void)
|
|||
log_err("toUnicodeLocaleKey: keyword=%s => %s, expected=NULL\n", keyword, bcpKey);
|
||||
}
|
||||
} else if (bcpKey == NULL) {
|
||||
log_err("toUnicodeLocaleKey: keyword=%s => NULL, expected=%s\n", keyword, expected);
|
||||
log_data_err("toUnicodeLocaleKey: keyword=%s => NULL, expected=%s\n", keyword, expected);
|
||||
} else if (uprv_strcmp(expected, "$IN") == 0) {
|
||||
if (bcpKey != keyword) {
|
||||
log_err("toUnicodeLocaleKey: keyword=%s => %s, expected=%s(input pointer)\n", keyword, bcpKey, keyword);
|
||||
|
@ -5931,7 +5931,7 @@ static void TestToLegacyKey(void)
|
|||
log_err("toLegacyKey: keyword=%s => %s, expected=%s(input pointer)\n", keyword, legacyKey, keyword);
|
||||
}
|
||||
} else if (uprv_strcmp(legacyKey, expected) != 0) {
|
||||
log_err("toUnicodeLocaleKey: keyword=%s, %s, expected=%s\n", keyword, legacyKey, expected);
|
||||
log_data_err("toUnicodeLocaleKey: keyword=%s, %s, expected=%s\n", keyword, legacyKey, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5977,13 +5977,13 @@ static void TestToUnicodeLocaleType(void)
|
|||
log_err("toUnicodeLocaleType: keyword=%s, value=%s => %s, expected=NULL\n", keyword, value, bcpType);
|
||||
}
|
||||
} else if (bcpType == NULL) {
|
||||
log_err("toUnicodeLocaleType: keyword=%s, value=%s => NULL, expected=%s\n", keyword, value, expected);
|
||||
log_data_err("toUnicodeLocaleType: keyword=%s, value=%s => NULL, expected=%s\n", keyword, value, expected);
|
||||
} else if (uprv_strcmp(expected, "$IN") == 0) {
|
||||
if (bcpType != value) {
|
||||
log_err("toUnicodeLocaleType: keyword=%s, value=%s => %s, expected=%s(input pointer)\n", keyword, value, bcpType, value);
|
||||
}
|
||||
} else if (uprv_strcmp(bcpType, expected) != 0) {
|
||||
log_err("toUnicodeLocaleType: keyword=%s, value=%s => %s, expected=%s\n", keyword, value, bcpType, expected);
|
||||
log_data_err("toUnicodeLocaleType: keyword=%s, value=%s => %s, expected=%s\n", keyword, value, bcpType, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6037,7 +6037,7 @@ static void TestToLegacyType(void)
|
|||
log_err("toLegacyType: keyword=%s, value=%s => %s, expected=%s(input pointer)\n", keyword, value, legacyType, value);
|
||||
}
|
||||
} else if (uprv_strcmp(legacyType, expected) != 0) {
|
||||
log_err("toLegacyType: keyword=%s, value=%s => %s, expected=%s\n", keyword, value, legacyType, expected);
|
||||
log_data_err("toLegacyType: keyword=%s, value=%s => %s, expected=%s\n", keyword, value, legacyType, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ static void TestQuickCheckResultYES()
|
|||
}
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFKD, &error) != UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check at U+%04x\n", cp);
|
||||
log_data_err("ERROR in NFKD quick check at U+%04x\n", cp);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFKC, &error) !=
|
||||
|
@ -460,7 +460,7 @@ static void TestQuickCheckResultMAYBE()
|
|||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) !=
|
||||
UNORM_MAYBE)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
|
||||
log_data_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ static void TestQuickCheckStringResult()
|
|||
if (unorm_quickCheck(d, u_strlen(d), UNORM_NFKD, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check for string at count %d\n", count);
|
||||
log_data_err("ERROR in NFKD quick check for string at count %d\n", count);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1416,11 +1416,11 @@ TestQuickCheckPerCP() {
|
|||
tccc2=u_getCombiningClass(trail);
|
||||
|
||||
if(lccc1!=lccc2) {
|
||||
log_err("u_getIntPropertyValue(lccc)=%d != %d=u_getCombiningClass(lead) for U+%04x\n",
|
||||
log_data_err("u_getIntPropertyValue(lccc)=%d != %d=u_getCombiningClass(lead) for U+%04x\n",
|
||||
lccc1, lccc2, c);
|
||||
}
|
||||
if(tccc1!=tccc2) {
|
||||
log_err("u_getIntPropertyValue(tccc)=%d != %d=u_getCombiningClass(trail) for U+%04x\n",
|
||||
log_data_err("u_getIntPropertyValue(tccc)=%d != %d=u_getCombiningClass(trail) for U+%04x\n",
|
||||
tccc1, tccc2, c);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static void assertEqualScripts(const char *msg,
|
|||
scriptsToString(scripts1, length1, s1);
|
||||
scriptsToString(scripts2, length2, s2);
|
||||
if(0!=strcmp(s1, s2)) {
|
||||
log_err("Failed: %s: expected %s but got %s\n", msg, s1, s2);
|
||||
log_data_err("Failed: %s: expected %s but got %s\n", msg, s1, s2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1838,7 +1838,10 @@ static void TestTZDataDir(void) {
|
|||
// Verify that default ICU time zone data version is something newer than 2014a.
|
||||
tzDataVersion = ucal_getTZDataVersion(&status);
|
||||
// printf("tz data version is %s\n", tzDataVersion);
|
||||
if (strcmp("2014a", tzDataVersion) == 0) {
|
||||
if (U_FAILURE(status)) {
|
||||
log_data_err("Failed call to ucal_getTZDataVersion - %s\n", u_errorName(status));
|
||||
return;
|
||||
} else if (strcmp("2014a", tzDataVersion) == 0) {
|
||||
log_err("File %s:%d - expected something newer than time zone data 2014a.\n", __FILE__, __LINE__, tzDataVersion);
|
||||
}
|
||||
|
||||
|
|
|
@ -2437,7 +2437,7 @@ void CollationAPITest::TestBadKeywords() {
|
|||
errorCode = U_ZERO_ERROR;
|
||||
coll.adoptInstead(Collator::createInstance(localeID, errorCode));
|
||||
if(errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
|
||||
errln("Collator::createInstance(%s) did not fail as expected - %s",
|
||||
dataerrln("Collator::createInstance(%s) did not fail as expected - %s",
|
||||
localeID, u_errorName(errorCode));
|
||||
}
|
||||
|
||||
|
@ -2458,10 +2458,10 @@ void CollationAPITest::TestBadKeywords() {
|
|||
errorCode = U_ZERO_ERROR;
|
||||
coll.adoptInstead(Collator::createInstance(localeID, errorCode));
|
||||
if(errorCode != U_UNSUPPORTED_ERROR) {
|
||||
if (errorCode == U_ILLEGAL_ARGUMENT_ERROR) {
|
||||
if (errorCode == U_ILLEGAL_ARGUMENT_ERROR || errorCode == U_FILE_ACCESS_ERROR) {
|
||||
dataerrln("Collator::createInstance(it-u-vt-u24) : %s", u_errorName(errorCode));
|
||||
} else {
|
||||
errln("Collator::createInstance(%s) did not fail as expected - %s",
|
||||
errln("Collator::createInstance(%s) did not fail as expected - %s",
|
||||
localeID, u_errorName(errorCode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4468,7 +4468,9 @@ void DateFormatTest::TestNumberFormatOverride() {
|
|||
|
||||
LocalPointer<SimpleDateFormat> fmt;
|
||||
fmt.adoptInstead(new SimpleDateFormat((UnicodeString)"MM d", status));
|
||||
assertSuccess("SimpleDateFormat with pattern MM d", status);
|
||||
if (!assertSuccess("SimpleDateFormat with pattern MM d", status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NumberFormat* check_nf = NumberFormat::createInstance(Locale("en_US"), status);
|
||||
assertSuccess("NumberFormat en_US", status);
|
||||
|
|
|
@ -1965,7 +1965,7 @@ void IntlTestRBNF::TestPluralRules() {
|
|||
UParseError parseError;
|
||||
RuleBasedNumberFormat enFormatter(enRules, Locale::getEnglish(), parseError, status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
|
||||
dataerrln("Unable to create RuleBasedNumberFormat - " + UnicodeString(u_errorName(status)));
|
||||
return;
|
||||
}
|
||||
const char* const enTestData[][2] = {
|
||||
|
|
|
@ -2542,10 +2542,10 @@ void LocaleTest::TestIsRightToLeft() {
|
|||
assertFalse("root LTR", Locale::getRoot().isRightToLeft());
|
||||
assertFalse("zh LTR", Locale::getChinese().isRightToLeft());
|
||||
assertTrue("ar RTL", Locale("ar").isRightToLeft());
|
||||
assertTrue("und-EG RTL", Locale("und-EG").isRightToLeft());
|
||||
assertTrue("und-EG RTL", Locale("und-EG").isRightToLeft(), FALSE, TRUE);
|
||||
assertFalse("fa-Cyrl LTR", Locale("fa-Cyrl").isRightToLeft());
|
||||
assertTrue("en-Hebr RTL", Locale("en-Hebr").isRightToLeft());
|
||||
assertTrue("ckb RTL", Locale("ckb").isRightToLeft()); // Sorani Kurdish
|
||||
assertTrue("ckb RTL", Locale("ckb").isRightToLeft(), FALSE, TRUE); // Sorani Kurdish
|
||||
assertFalse("fil LTR", Locale("fil").isRightToLeft());
|
||||
assertFalse("he-Zyxw LTR", Locale("he-Zyxw").isRightToLeft());
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0);
|
||||
private:
|
||||
void assertPatternFr(
|
||||
const char *expected, double x, const char *pattern);
|
||||
const char *expected, double x, const char *pattern, UBool possibleDataError=FALSE);
|
||||
|
||||
};
|
||||
|
||||
|
@ -84,98 +84,98 @@ void NumberFormatSpecificationTest::runIndexedTest(
|
|||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestBasicPatterns() {
|
||||
assertPatternFr("1 234,57", 1234.567, "#,##0.##");
|
||||
assertPatternFr("1234,57", 1234.567, "0.##");
|
||||
assertPatternFr("1235", 1234.567, "0");
|
||||
assertPatternFr("1 234,567", 1234.567, "#,##0.###");
|
||||
assertPatternFr("1234,567", 1234.567, "###0.#####");
|
||||
assertPatternFr("1234,5670", 1234.567, "###0.0000#");
|
||||
assertPatternFr("01234,5670", 1234.567, "00000.0000");
|
||||
assertPatternFr("1 234,57 \\u20ac", 1234.567, "#,##0.00 \\u00a4");
|
||||
assertPatternFr("1 234,57", 1234.567, "#,##0.##", TRUE);
|
||||
assertPatternFr("1234,57", 1234.567, "0.##", TRUE);
|
||||
assertPatternFr("1235", 1234.567, "0", TRUE);
|
||||
assertPatternFr("1 234,567", 1234.567, "#,##0.###", TRUE);
|
||||
assertPatternFr("1234,567", 1234.567, "###0.#####", TRUE);
|
||||
assertPatternFr("1234,5670", 1234.567, "###0.0000#", TRUE);
|
||||
assertPatternFr("01234,5670", 1234.567, "00000.0000", TRUE);
|
||||
assertPatternFr("1 234,57 \\u20ac", 1234.567, "#,##0.00 \\u00a4", TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestNfSetters() {
|
||||
LocalPointer<NumberFormat> nf(nfWithPattern("#,##0.##"));
|
||||
nf->setMaximumIntegerDigits(5);
|
||||
nf->setMinimumIntegerDigits(4);
|
||||
assertEquals("", "34 567,89", format(1234567.89, *nf));
|
||||
assertEquals("", "0 034,56", format(34.56, *nf));
|
||||
assertEquals("", "34 567,89", format(1234567.89, *nf), TRUE);
|
||||
assertEquals("", "0 034,56", format(34.56, *nf), TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestRounding() {
|
||||
assertPatternFr("1,0", 1.25, "0.5");
|
||||
assertPatternFr("2,0", 1.75, "0.5");
|
||||
assertPatternFr("-1,0", -1.25, "0.5");
|
||||
assertPatternFr("-02,0", -1.75, "00.5");
|
||||
assertPatternFr("0", 2.0, "4");
|
||||
assertPatternFr("8", 6.0, "4");
|
||||
assertPatternFr("8", 10.0, "4");
|
||||
assertPatternFr("99,90", 99.0, "2.70");
|
||||
assertPatternFr("273,00", 272.0, "2.73");
|
||||
assertPatternFr("1 03,60", 104.0, "#,#3.70");
|
||||
assertPatternFr("1,0", 1.25, "0.5", TRUE);
|
||||
assertPatternFr("2,0", 1.75, "0.5", TRUE);
|
||||
assertPatternFr("-1,0", -1.25, "0.5", TRUE);
|
||||
assertPatternFr("-02,0", -1.75, "00.5", TRUE);
|
||||
assertPatternFr("0", 2.0, "4", TRUE);
|
||||
assertPatternFr("8", 6.0, "4", TRUE);
|
||||
assertPatternFr("8", 10.0, "4", TRUE);
|
||||
assertPatternFr("99,90", 99.0, "2.70", TRUE);
|
||||
assertPatternFr("273,00", 272.0, "2.73", TRUE);
|
||||
assertPatternFr("1 03,60", 104.0, "#,#3.70", TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestSignificantDigits() {
|
||||
assertPatternFr("1230", 1234.0, "@@@");
|
||||
assertPatternFr("1 234", 1234.0, "@,@@@");
|
||||
assertPatternFr("1 235 000", 1234567.0, "@,@@@");
|
||||
assertPatternFr("1 234 567", 1234567.0, "@@@@,@@@");
|
||||
assertPatternFr("12 34 567,00", 1234567.0, "@@@@,@@,@@@");
|
||||
assertPatternFr("12 34 567,0", 1234567.0, "@@@@,@@,@@#");
|
||||
assertPatternFr("12 34 567", 1234567.0, "@@@@,@@,@##");
|
||||
assertPatternFr("12 34 567", 1234567.001, "@@@@,@@,@##");
|
||||
assertPatternFr("12 34 567", 1234567.001, "@@@@,@@,###");
|
||||
assertPatternFr("1 200", 1234.0, "#,#@@");
|
||||
assertPatternFr("1230", 1234.0, "@@@", TRUE);
|
||||
assertPatternFr("1 234", 1234.0, "@,@@@", TRUE);
|
||||
assertPatternFr("1 235 000", 1234567.0, "@,@@@", TRUE);
|
||||
assertPatternFr("1 234 567", 1234567.0, "@@@@,@@@", TRUE);
|
||||
assertPatternFr("12 34 567,00", 1234567.0, "@@@@,@@,@@@", TRUE);
|
||||
assertPatternFr("12 34 567,0", 1234567.0, "@@@@,@@,@@#", TRUE);
|
||||
assertPatternFr("12 34 567", 1234567.0, "@@@@,@@,@##", TRUE);
|
||||
assertPatternFr("12 34 567", 1234567.001, "@@@@,@@,@##", TRUE);
|
||||
assertPatternFr("12 34 567", 1234567.001, "@@@@,@@,###", TRUE);
|
||||
assertPatternFr("1 200", 1234.0, "#,#@@", TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestScientificNotation() {
|
||||
assertPatternFr("1,23E4", 12345.0, "0.00E0");
|
||||
assertPatternFr("123,00E2", 12300.0, "000.00E0");
|
||||
assertPatternFr("123,0E2", 12300.0, "000.0#E0");
|
||||
assertPatternFr("123,0E2", 12300.1, "000.0#E0");
|
||||
assertPatternFr("123,01E2", 12301.0, "000.0#E0");
|
||||
assertPatternFr("123,01E+02", 12301.0, "000.0#E+00");
|
||||
assertPatternFr("12,3E3", 12345.0, "##0.00E0");
|
||||
assertPatternFr("12,300E3", 12300.1, "##0.0000E0");
|
||||
assertPatternFr("12,30E3", 12300.1, "##0.000#E0");
|
||||
assertPatternFr("12,301E3", 12301.0, "##0.000#E0");
|
||||
assertPatternFr("1,23E4", 12345.0, "0.00E0", TRUE);
|
||||
assertPatternFr("123,00E2", 12300.0, "000.00E0", TRUE);
|
||||
assertPatternFr("123,0E2", 12300.0, "000.0#E0", TRUE);
|
||||
assertPatternFr("123,0E2", 12300.1, "000.0#E0", TRUE);
|
||||
assertPatternFr("123,01E2", 12301.0, "000.0#E0", TRUE);
|
||||
assertPatternFr("123,01E+02", 12301.0, "000.0#E+00", TRUE);
|
||||
assertPatternFr("12,3E3", 12345.0, "##0.00E0", TRUE);
|
||||
assertPatternFr("12,300E3", 12300.1, "##0.0000E0", TRUE);
|
||||
assertPatternFr("12,30E3", 12300.1, "##0.000#E0", TRUE);
|
||||
assertPatternFr("12,301E3", 12301.0, "##0.000#E0", TRUE);
|
||||
if (!logKnownIssue("11020")) {
|
||||
assertPatternFr("1,25E4", 12301.2, "0.05E0");
|
||||
}
|
||||
assertPatternFr("170,0E-3", 0.17, "##0.000#E0");
|
||||
assertPatternFr("170,0E-3", 0.17, "##0.000#E0", TRUE);
|
||||
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestPercent() {
|
||||
assertPatternFr("57,3%", 0.573, "0.0%");
|
||||
assertPatternFr("%57,3", 0.573, "%0.0");
|
||||
assertPatternFr("p%p57,3", 0.573, "p%p0.0");
|
||||
assertPatternFr("p%p0,6", 0.573, "p'%'p0.0");
|
||||
assertPatternFr("%3,260", 0.0326, "%@@@@");
|
||||
assertPatternFr("%1 540", 15.43, "%#,@@@");
|
||||
assertPatternFr("%1 656,4", 16.55, "%#,##4.1");
|
||||
assertPatternFr("%16,3E3", 162.55, "%##0.00E0");
|
||||
assertPatternFr("57,3%", 0.573, "0.0%", TRUE);
|
||||
assertPatternFr("%57,3", 0.573, "%0.0", TRUE);
|
||||
assertPatternFr("p%p57,3", 0.573, "p%p0.0", TRUE);
|
||||
assertPatternFr("p%p0,6", 0.573, "p'%'p0.0", TRUE);
|
||||
assertPatternFr("%3,260", 0.0326, "%@@@@", TRUE);
|
||||
assertPatternFr("%1 540", 15.43, "%#,@@@", TRUE);
|
||||
assertPatternFr("%1 656,4", 16.55, "%#,##4.1", TRUE);
|
||||
assertPatternFr("%16,3E3", 162.55, "%##0.00E0", TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestPerMilli() {
|
||||
assertPatternFr("573,0\\u2030", 0.573, "0.0\\u2030");
|
||||
assertPatternFr("\\u2030573,0", 0.573, "\\u20300.0");
|
||||
assertPatternFr("p\\u2030p573,0", 0.573, "p\\u2030p0.0");
|
||||
assertPatternFr("p\\u2030p0,6", 0.573, "p'\\u2030'p0.0");
|
||||
assertPatternFr("\\u203032,60", 0.0326, "\\u2030@@@@");
|
||||
assertPatternFr("\\u203015 400", 15.43, "\\u2030#,@@@");
|
||||
assertPatternFr("\\u203016 551,7", 16.55, "\\u2030#,##4.1");
|
||||
assertPatternFr("\\u2030163E3", 162.55, "\\u2030##0.00E0");
|
||||
assertPatternFr("573,0\\u2030", 0.573, "0.0\\u2030", TRUE);
|
||||
assertPatternFr("\\u2030573,0", 0.573, "\\u20300.0", TRUE);
|
||||
assertPatternFr("p\\u2030p573,0", 0.573, "p\\u2030p0.0", TRUE);
|
||||
assertPatternFr("p\\u2030p0,6", 0.573, "p'\\u2030'p0.0", TRUE);
|
||||
assertPatternFr("\\u203032,60", 0.0326, "\\u2030@@@@", TRUE);
|
||||
assertPatternFr("\\u203015 400", 15.43, "\\u2030#,@@@", TRUE);
|
||||
assertPatternFr("\\u203016 551,7", 16.55, "\\u2030#,##4.1", TRUE);
|
||||
assertPatternFr("\\u2030163E3", 162.55, "\\u2030##0.00E0", TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::TestPadding() {
|
||||
assertPatternFr("$***1 234", 1234, "$**####,##0");
|
||||
assertPatternFr("xxx$1 234", 1234, "*x$####,##0");
|
||||
assertPatternFr("1 234xxx$", 1234, "####,##0*x$");
|
||||
assertPatternFr("1 234$xxx", 1234, "####,##0$*x");
|
||||
assertPatternFr("ne1 234nx", -1234, "####,##0$*x;ne#n");
|
||||
assertPatternFr("n1 234*xx", -1234, "####,##0$*x;n#'*'");
|
||||
assertPatternFr("yyyy%432,6", 4.33, "*y%4.2######");
|
||||
assertPatternFr("$***1 234", 1234, "$**####,##0", TRUE);
|
||||
assertPatternFr("xxx$1 234", 1234, "*x$####,##0", TRUE);
|
||||
assertPatternFr("1 234xxx$", 1234, "####,##0*x$", TRUE);
|
||||
assertPatternFr("1 234$xxx", 1234, "####,##0$*x", TRUE);
|
||||
assertPatternFr("ne1 234nx", -1234, "####,##0$*x;ne#n", TRUE);
|
||||
assertPatternFr("n1 234*xx", -1234, "####,##0$*x;n#'*'", TRUE);
|
||||
assertPatternFr("yyyy%432,6", 4.33, "*y%4.2######", TRUE);
|
||||
if (!logKnownIssue("11025")) {
|
||||
assertPatternFr("EUR *433,00", 433.0, "\\u00a4\\u00a4 **####0.00");
|
||||
assertPatternFr("EUR *433,00", 433.0, "\\u00a4\\u00a4 **#######0");
|
||||
|
@ -190,7 +190,7 @@ void NumberFormatSpecificationTest::TestPadding() {
|
|||
fmt.setCurrency(kJPY);
|
||||
fmt.format(433.22, result);
|
||||
assertSuccess("", status);
|
||||
assertEquals("", "JPY ****433", result);
|
||||
assertEquals("", "JPY ****433", result, TRUE);
|
||||
}
|
||||
{
|
||||
UnicodeString upattern(
|
||||
|
@ -204,10 +204,10 @@ void NumberFormatSpecificationTest::TestPadding() {
|
|||
status);
|
||||
fmt.format(-433.22, result);
|
||||
assertSuccess("", status);
|
||||
assertEquals("", "USD (433.22)", result);
|
||||
assertEquals("", "USD (433.22)", result, TRUE);
|
||||
}
|
||||
const char *paddedSciPattern = "QU**00.#####E0";
|
||||
assertPatternFr("QU***43,3E-1", 4.33, paddedSciPattern);
|
||||
assertPatternFr("QU***43,3E-1", 4.33, paddedSciPattern, TRUE);
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
DecimalFormatSymbols *sym = new DecimalFormatSymbols("fr", status);
|
||||
|
@ -219,16 +219,17 @@ void NumberFormatSpecificationTest::TestPadding() {
|
|||
UnicodeString result;
|
||||
fmt.format(4.33, result);
|
||||
assertSuccess("", status);
|
||||
assertEquals("", "QU**43,3EE-1", result);
|
||||
assertEquals("", "QU**43,3EE-1", result, TRUE);
|
||||
}
|
||||
// padding cannot work as intended with scientific notation.
|
||||
assertPatternFr("QU**43,32E-1", 4.332, paddedSciPattern);
|
||||
assertPatternFr("QU**43,32E-1", 4.332, paddedSciPattern, TRUE);
|
||||
}
|
||||
|
||||
void NumberFormatSpecificationTest::assertPatternFr(
|
||||
const char *expected,
|
||||
double x,
|
||||
const char *pattern) {
|
||||
const char *pattern,
|
||||
UBool possibleDataError) {
|
||||
UnicodeString upattern(pattern, -1, US_INV);
|
||||
UnicodeString uexpected(expected, -1, US_INV);
|
||||
upattern = upattern.unescape();
|
||||
|
@ -240,7 +241,7 @@ void NumberFormatSpecificationTest::assertPatternFr(
|
|||
fmt.format(x, result);
|
||||
fixNonBreakingSpace(result);
|
||||
assertSuccess("", status);
|
||||
assertEquals("", uexpected, result);
|
||||
assertEquals("", uexpected, result, possibleDataError);
|
||||
}
|
||||
|
||||
extern IntlTest *createNumberFormatSpecificationTest() {
|
||||
|
|
|
@ -126,7 +126,7 @@ void QuantityFormatterTest::TestBasic() {
|
|||
*plurrule,
|
||||
appendTo,
|
||||
pos,
|
||||
status));
|
||||
status), TRUE);
|
||||
appendTo.remove();
|
||||
assertEquals(
|
||||
"format plural",
|
||||
|
@ -137,7 +137,7 @@ void QuantityFormatterTest::TestBasic() {
|
|||
*plurrule,
|
||||
appendTo,
|
||||
pos,
|
||||
status));
|
||||
status), TRUE);
|
||||
}
|
||||
fmt.reset();
|
||||
assertFalse("isValid after reset", fmt.isValid());
|
||||
|
|
|
@ -1244,15 +1244,17 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
|
|||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(20 == filteredBI->next()); // Mr.
|
||||
TEST_ASSERT(84 == filteredBI->next()); // recovered.
|
||||
TEST_ASSERT(90 == filteredBI->next()); // Capt.
|
||||
TEST_ASSERT(181 == filteredBI->next()); // Mr.
|
||||
TEST_ASSERT(278 == filteredBI->next()); // charge.
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
if (U_SUCCESS(status)) {
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(20 == filteredBI->next()); // Mr.
|
||||
TEST_ASSERT(84 == filteredBI->next()); // recovered.
|
||||
TEST_ASSERT(90 == filteredBI->next()); // Capt.
|
||||
TEST_ASSERT(181 == filteredBI->next()); // Mr.
|
||||
TEST_ASSERT(278 == filteredBI->next()); // charge.
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1260,29 +1262,31 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
|
|||
builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Adding Mr. as an exception\n");
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(FALSE == builder->suppressBreakAfter(ABBR_MR, status)); // already have it
|
||||
TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(FALSE == builder->unsuppressBreakAfter(ABBR_MR, status)); // already removed it
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
if (U_SUCCESS(status)) {
|
||||
logln("Adding Mr. as an exception\n");
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(FALSE == builder->suppressBreakAfter(ABBR_MR, status)); // already have it
|
||||
TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(FALSE == builder->unsuppressBreakAfter(ABBR_MR, status)); // already removed it
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(90 == filteredBI->next());// Capt.
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(90 == filteredBI->next());// Capt.
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1291,52 +1295,26 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
|
|||
builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Adding Mr. and Capt as an exception\n");
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_CAPT, status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
if (U_SUCCESS(status)) {
|
||||
logln("Adding Mr. and Capt as an exception\n");
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_MR, status));
|
||||
TEST_ASSERT(TRUE == builder->suppressBreakAfter(ABBR_CAPT, status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
logln("Constructing English builder\n");
|
||||
builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("unsuppressing 'Capt'");
|
||||
TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_CAPT, status));
|
||||
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
if(filteredBI.isValid()) {
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(90 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1350,17 +1328,49 @@ void RBBIAPITest::TestFilteredBreakIteratorBuilder() {
|
|||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
if (U_SUCCESS(status)) {
|
||||
logln("unsuppressing 'Capt'");
|
||||
TEST_ASSERT(TRUE == builder->unsuppressBreakAfter(ABBR_CAPT, status));
|
||||
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
if(filteredBI.isValid()) {
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(90 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
logln("Constructing English builder\n");
|
||||
builder.adoptInstead(FilteredBreakIteratorBuilder::createInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
if(filteredBI.isValid()) {
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
logln("Constructing base BI\n");
|
||||
baseBI.adoptInstead(BreakIterator::createSentenceInstance(Locale::getEnglish(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
if (U_SUCCESS(status)) {
|
||||
logln("Building new BI\n");
|
||||
filteredBI.adoptInstead(builder->build(baseBI.orphan(), status));
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
|
||||
if(filteredBI.isValid()) {
|
||||
logln("Testing:");
|
||||
filteredBI->setText(text);
|
||||
TEST_ASSERT(84 == filteredBI->next());
|
||||
TEST_ASSERT(278 == filteredBI->next());
|
||||
filteredBI->first();
|
||||
prtbrks(filteredBI.getAlias(), text, *this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1477,7 +1477,7 @@ void TransliteratorTest::TestNormalizationTransliterator() {
|
|||
Transliterator* NFKD = Transliterator::createInstance("NFKD", UTRANS_FORWARD, parseError, status);
|
||||
Transliterator* NFKC = Transliterator::createInstance("NFKC", UTRANS_FORWARD, parseError, status);
|
||||
if (!NFKD || !NFKC) {
|
||||
errln("FAIL: createInstance failed");
|
||||
dataerrln("FAIL: createInstance failed");
|
||||
delete NFKD;
|
||||
delete NFKC;
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue