/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2008, International Business Machines Corporation and
+ * Copyright (c) 1997-2010, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* display language (Catalan) */
{ "angl\\u00E8s", "franc\\u00E8s", "catal\\u00E0", "grec", "noruec", "itali\\u00E0", "", "xin\\u00E8s" },
/* display script (Catalan) */
- { "", "", "", "", "", "", "", "Xin\\u00E8s Simplificat (Han)" },
+ { "", "", "", "", "", "", "", "xin\\u00E8s simplificat" },
/* display country (Catalan) */
{ "Estats Units", "Fran\\u00E7a", "Espanya", "Gr\\u00E8cia", "Noruega", "", "", "Xina" },
/* display variant (Catalan) */
{ "", "", "", "", "NY", "", "" },
/* display name (Catalan) */
- { "angl\\u00E8s (Estats Units)", "franc\\u00E8s (Fran\\u00E7a)", "catal\\u00E0 (Espanya)", "grec (Gr\\u00E8cia)", "noruec (Noruega, NY)", "itali\\u00E0", "", "xin\\u00E8s (Xin\\u00E8s Simplificat (Han), Xina)" },
+ { "angl\\u00E8s (Estats Units)", "franc\\u00E8s (Fran\\u00E7a)", "catal\\u00E0 (Espanya)", "grec (Gr\\u00E8cia)", "noruec (Noruega, NY)", "itali\\u00E0", "", "xin\\u00E8s (xin\\u00E8s simplificat, Xina)" },
// display langage (Greek)[actual values listed below]
{ "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac",
"\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC"
},
// display script (Greek)
- { "", "", "", "", "", "", "", "\\u039a\\u03b9\\u03bd\\u03b5\\u03b6\\u03b9\\u03ba\\u03cc \\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf" },
+ { "", "", "", "", "", "", "", "\\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf \\u039a\\u03b9\\u03bd\\u03b5\\u03b6\\u03b9\\u03ba\\u03cc" },
// display country (Greek)[actual values listed below]
- { "\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2",
+ { "\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2 \\u03C4\\u03B7\\u03C2 \\u0391\\u03BC\\u03B5\\u03C1\\u03B9\\u03BA\\u03AE\\u03C2",
"\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1",
"\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1",
"\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1",
// display variant (Greek)
{ "", "", "", "", "NY", "", "" },
// display name (Greek)[actual values listed below]
- { "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac (\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2)",
+ { "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac (\\u0397\\u03BD\\u03C9\\u03BC\\u03AD\\u03BD\\u03B5\\u03C2 \\u03A0\\u03BF\\u03BB\\u03B9\\u03C4\\u03B5\\u03AF\\u03B5\\u03C2 \\u03C4\\u03B7\\u03C2 \\u0391\\u03BC\\u03B5\\u03C1\\u03B9\\u03BA\\u03AE\\u03C2)",
"\\u0393\\u03b1\\u03bb\\u03bb\\u03b9\\u03ba\\u03ac (\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1)",
"\\u039a\\u03b1\\u03c4\\u03b1\\u03bb\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac (\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1)",
"\\u0395\\u03bb\\u03bb\\u03b7\\u03bd\\u03b9\\u03ba\\u03ac (\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1)",
"\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03b9\\u03ba\\u03ac (\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03af\\u03b1, NY)",
"\\u0399\\u03c4\\u03b1\\u03bb\\u03b9\\u03ba\\u03ac",
"",
- "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC (\\u039a\\u03b9\\u03bd\\u03b5\\u03b6\\u03b9\\u03ba\\u03cc \\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf, \\u039A\\u03AF\\u03BD\\u03B1)"
+ "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC (\\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03bf \\u039a\\u03b9\\u03bd\\u03b5\\u03b6\\u03b9\\u03ba\\u03cc, \\u039A\\u03AF\\u03BD\\u03B1)"
},
// display langage (<root>)
TESTCASE(23, TestParallelAPIValues);
TESTCASE(24, TestKeywordVariants);
TESTCASE(25, TestKeywordVariantParsing);
- TESTCASE(26, TestGetBaseName);
- TESTCASE(27, TestGetLocale);
- TESTCASE(28, TestVariantWithOutCountry);
- TESTCASE(29, TestCanonicalization);
- TESTCASE(30, TestCurrencyByDate);
+ TESTCASE(26, TestSetKeywordValue);
+ TESTCASE(27, TestGetBaseName);
+#if !UCONFIG_NO_FILE_IO
+ TESTCASE(28, TestGetLocale);
+#endif
+ TESTCASE(29, TestVariantWithOutCountry);
+ TESTCASE(30, TestCanonicalization);
+ TESTCASE(31, TestCurrencyByDate);
+ TESTCASE(32, TestGetVariantWithKeywords);
// keep the last index in sync with the condition in default:
/* Check to see if ICU supports this locale */
if (symb.getLocale(ULOC_VALID_LOCALE, status) != Locale("root")) {
/* test that the default locale has a display name for its own language */
- Locale().getDisplayLanguage(Locale(), s);
- if(s.length()<=3 && s.charAt(0)<=0x7f) {
- /* check <=3 to reject getting the language code as a display name */
- errln("unable to get a display string for the language of the default locale\n");
- }
+ /* Currently, there is no language information in the "tl" data file so this test will fail if default locale is "tl" */
+ if (uprv_strcmp(Locale().getLanguage(), "tl") != 0) {
+ Locale().getDisplayLanguage(Locale(), s);
+ if(s.length()<=3 && s.charAt(0)<=0x7f) {
+ /* check <=3 to reject getting the language code as a display name */
+ dataerrln("unable to get a display string for the language of the default locale: " + s);
+ }
- /*
- * API coverage improvements: call
- * Locale::getDisplayLanguage(UnicodeString &) and
- * Locale::getDisplayCountry(UnicodeString &)
- */
- s.remove();
- Locale().getDisplayLanguage(s);
- if(s.length()<=3 && s.charAt(0)<=0x7f) {
- errln("unable to get a display string for the language of the default locale [2]\n");
+ /*
+ * API coverage improvements: call
+ * Locale::getDisplayLanguage(UnicodeString &) and
+ * Locale::getDisplayCountry(UnicodeString &)
+ */
+ s.remove();
+ Locale().getDisplayLanguage(s);
+ if(s.length()<=3 && s.charAt(0)<=0x7f) {
+ dataerrln("unable to get a display string for the language of the default locale [2]: " + s);
+ }
}
}
else {
const Locale* locList = Locale::getAvailableLocales(locCount);
if (locCount == 0)
- errln("getAvailableLocales() returned an empty list!");
+ dataerrln("getAvailableLocales() returned an empty list!");
else {
logln(UnicodeString("Number of locales returned = ") + locCount);
UnicodeString temp;
expectedName = dataTable[DNAME_EN][i];
if (testLang != expectedLang)
- errln("Display language (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testLang + " expected " + expectedLang);
+ dataerrln("Display language (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testLang + " expected " + expectedLang);
if (testScript != expectedScript)
- errln("Display script (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testScript + " expected " + expectedScript);
+ dataerrln("Display script (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testScript + " expected " + expectedScript);
if (testCtry != expectedCtry)
- errln("Display country (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testCtry + " expected " + expectedCtry);
+ dataerrln("Display country (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testCtry + " expected " + expectedCtry);
if (testVar != expectedVar)
- errln("Display variant (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testVar + " expected " + expectedVar);
+ dataerrln("Display variant (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testVar + " expected " + expectedVar);
if (testName != expectedName)
- errln("Display name (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testName + " expected " + expectedName);
+ dataerrln("Display name (" + UnicodeString(displayLocale.getName()) + ") of (" + UnicodeString(testLocale.getName()) + ") got " + testName + " expected " + expectedName);
}
}
;
/* TODO: Change this test to be more like the cloctst version? */
- if (testCount != 489)
- errln("Expected getISOLanguages() to return 489 languages; it returned %d", testCount);
+ if (testCount != 491)
+ errln("Expected getISOLanguages() to return 491 languages; it returned %d", testCount);
else {
for (i = 0; i < 15; i++) {
int32_t j;
Locale l(languageCodes[i], "", "");
l.getDisplayLanguage(Locale::getUS(), test);
if (test != languageNames[i])
- errln("Got wrong display name for " + UnicodeString(languageCodes[i]) + ": Expected \"" +
+ dataerrln("Got wrong display name for " + UnicodeString(languageCodes[i]) + ": Expected \"" +
languageNames[i] + "\", got \"" + test + "\".");
}
}
logln(name);
if (name != englishDisplayNames[i])
{
- errln("Lookup in English failed: expected \"" + englishDisplayNames[i]
+ dataerrln("Lookup in English failed: expected \"" + englishDisplayNames[i]
+ "\", got \"" + name + "\"");
logln("Locale name was-> " + (name=localesToTest[i].getName()));
}
localesToTest[i].getDisplayName(Locale("es", "ES"), name);
logln(name);
if (name != spanishDisplayNames[i])
- errln("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
+ dataerrln("Lookup in Spanish failed: expected \"" + spanishDisplayNames[i]
+ "\", got \"" + name + "\"");
}
localesToTest[i].getDisplayName(Locale::getFrance(), name);
logln(name);
if (name != frenchDisplayNames[i])
- errln("Lookup in French failed: expected \"" + frenchDisplayNames[i]
+ dataerrln("Lookup in French failed: expected \"" + frenchDisplayNames[i]
+ "\", got \"" + name + "\"");
}
localesToTest[i].getDisplayName(Locale("inv", "IN"), name);
logln(name + " Locale fallback to be, and data fallback to root");
if (name != invDisplayNames[i])
- errln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
+ dataerrln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
+ "\", got \"" + prettify(name) + "\"");
localesToTest[i].getDisplayName(Locale("inv", "BD"), name);
logln(name + " Data fallback to root");
if (name != invDisplayNames[i])
- errln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
+ dataerrln("Lookup in INV failed: expected \"" + prettify(invDisplayNames[i])
+ "\", got \"" + prettify(name )+ "\"");
}
Locale::setDefault(saveLocale, status);
if(U_FAILURE(status) || !thaiCurrency)
{
- errln("Couldn't get th_TH currency -> " + UnicodeString(u_errorName(status)));
+ dataerrln("Couldn't get th_TH currency -> " + UnicodeString(u_errorName(status)));
return;
}
if (thaiCurrency->getPositivePrefix(temp) != UnicodeString(&posPrefix, 1, 1))
ucurr_forLocale("en_US", tmp, 4, &status);
resultStr.setTo(tmp);
if (dollarStr != resultStr) {
- errln("Fail: en_US didn't return USD");
+ errcheckln(status, "Fail: en_US didn't return USD - %s", u_errorName(status));
}
ucurr_forLocale("en_US_EURO", tmp, 4, &status);
resultStr.setTo(tmp);
if (euroStr != resultStr) {
- errln("Fail: en_US_EURO didn't return EUR");
+ errcheckln(status, "Fail: en_US_EURO didn't return EUR - %s", u_errorName(status));
}
ucurr_forLocale("en_GB_EURO", tmp, 4, &status);
resultStr.setTo(tmp);
if (euroStr != resultStr) {
- errln("Fail: en_GB_EURO didn't return EUR");
+ errcheckln(status, "Fail: en_GB_EURO didn't return EUR - %s", u_errorName(status));
}
ucurr_forLocale("en_US_PREEURO", tmp, 4, &status);
resultStr.setTo(tmp);
if (dollarStr != resultStr) {
- errln("Fail: en_US_PREEURO didn't fallback to en_US");
+ errcheckln(status, "Fail: en_US_PREEURO didn't fallback to en_US - %s", u_errorName(status));
}
ucurr_forLocale("en_US_Q", tmp, 4, &status);
resultStr.setTo(tmp);
if (dollarStr != resultStr) {
- errln("Fail: en_US_Q didn't fallback to en_US");
+ errcheckln(status, "Fail: en_US_Q didn't fallback to en_US - %s", u_errorName(status));
}
int32_t invalidLen = ucurr_forLocale("en_QQ", tmp, 4, &status);
if (invalidLen || U_SUCCESS(status)) {
UErrorCode status = U_ZERO_ERROR;
SimpleDateFormat df_full("EEEE", mylocale, status);
if(U_FAILURE(status)){
- errln(UnicodeString("Could not create SimpleDateFormat object for locale hu. Error: " )+ UnicodeString(u_errorName(status)));
+ dataerrln(UnicodeString("Could not create SimpleDateFormat object for locale hu. Error: ") + UnicodeString(u_errorName(status)));
return;
}
UnicodeString str;
UChar ocf = 0x00f4;
UChar oda = 0x0151;
if (str.indexOf(oda) < 0 || str.indexOf(ocf) >= 0) {
- errln("Fail: Monday in Hungarian is wrong - oda's index is %d and ocf's is %d",
- str.indexOf(oda), str.indexOf(ocf));
+ /* If the default locale is "th" this test will fail because of the buddhist calendar. */
+ if (strcmp(Locale::getDefault().getLanguage(), "th") != 0) {
+ errln("Fail: Monday in Hungarian is wrong - oda's index is %d and ocf's is %d",
+ str.indexOf(oda), str.indexOf(ocf));
+ } else {
+ logln(UnicodeString("An error is produce in buddhist calendar."));
+ }
logln(UnicodeString("String is: ") + str );
}
}
Calendar *cal = Calendar::createInstance(Locale("ru", "", ""), status);
if(U_SUCCESS(status)) {
if (cal->getFirstDayOfWeek(status) != UCAL_MONDAY) {
- errln("Fail: First day of week in Russia should be Monday");
+ dataerrln("Fail: First day of week in Russia should be Monday");
}
}
delete cal;
Locale loc = locales[i];
UnicodeString temp;
if (loc.getDisplayName(temp) != englishDisplayNames[i])
- errln("English display-name mismatch: expected " +
+ dataerrln("English display-name mismatch: expected " +
englishDisplayNames[i] + ", got " + loc.getDisplayName(temp));
if (loc.getDisplayName(loc, temp) != norwegianDisplayNames[i])
- errln("Norwegian display-name mismatch: expected " +
+ dataerrln("Norwegian display-name mismatch: expected " +
norwegianDisplayNames[i] + ", got " +
loc.getDisplayName(loc, temp));
}
en_US_custom.getDisplayName(Locale::getUS(), got);
if(got != dispName) {
- errln("FAIL: getDisplayName()");
- errln("Wanted: " + dispName);
- errln("Got : " + got);
+ dataerrln("FAIL: getDisplayName()");
+ dataerrln("Wanted: " + dispName);
+ dataerrln("Got : " + got);
}
Locale shortVariant("fr", "FR", "foo");
for (int32_t i = 0; i < 4; ++i) {
NumberFormat *fmt = NumberFormat::createPercentInstance(LOC[i], status);
if(U_FAILURE(status)) {
- errln("Couldn't create NumberFormat");
+ dataerrln("Couldn't create NumberFormat - %s", u_errorName(status));
return;
}
UnicodeString result;
}
}
+void
+LocaleTest::TestSetKeywordValue(void) {
+ static const struct {
+ const char *keyword;
+ const char *value;
+ } testCases[] = {
+ { "collation", "phonebook" },
+ { "currency", "euro" },
+ { "calendar", "buddhist" }
+ };
+
+ UErrorCode status = U_ZERO_ERROR;
+
+ int32_t i = 0;
+ int32_t resultLen = 0;
+ char buffer[256];
+
+ Locale l(Locale::getGerman());
+
+ for(i = 0; i < (int32_t)(sizeof(testCases)/sizeof(testCases[0])); i++) {
+ l.setKeywordValue(testCases[i].keyword, testCases[i].value, status);
+ if(U_FAILURE(status)) {
+ err("FAIL: Locale::setKeywordValue failed - %s\n", u_errorName(status));
+ }
+
+ *buffer = 0;
+ resultLen = l.getKeywordValue(testCases[i].keyword, buffer, 256, status);
+ if(uprv_strcmp(testCases[i].value, buffer) != 0) {
+ err("Expected to extract \"%s\" for keyword \"%s\". Got \"%s\" instead\n",
+ testCases[i].value, testCases[i].keyword, buffer);
+ }
+ }
+}
+
void
LocaleTest::TestGetBaseName(void) {
static const struct {
logln("%s; req=%s, valid=%s, actual=%s",
label, req, valid, actual);
} else {
- errln("FAIL: %s; req=%s, valid=%s, actual=%s. Require (R %s V) and (V %s A)",
+ dataerrln("FAIL: %s; req=%s, valid=%s, actual=%s. Require (R %s V) and (V %s A)",
label, req, valid, actual,
expReqValid, expValidActual);
}
req = "en_US_BROOKLYN";
Calendar* cal = Calendar::createInstance(Locale::createFromName(req), ec);
if (U_FAILURE(ec)) {
- errln("FAIL: Calendar::createInstance failed");
+ dataerrln("FAIL: Calendar::createInstance failed - %s", u_errorName(ec));
} else {
valid = cal->getLocale(ULOC_VALID_LOCALE, ec);
actual = cal->getLocale(ULOC_ACTUAL_LOCALE, ec);
// DecimalFormat, DecimalFormatSymbols
#if !UCONFIG_NO_FORMATTING
req = "fr_FR_NICE";
- DecimalFormat* dec = (DecimalFormat*)
- NumberFormat::createInstance(Locale::createFromName(req), ec);
+ NumberFormat* nf = NumberFormat::createInstance(Locale::createFromName(req), ec);
if (U_FAILURE(ec)) {
- errln("FAIL: NumberFormat::createInstance failed");
+ dataerrln("FAIL: NumberFormat::createInstance failed - %s", u_errorName(ec));
} else {
- if (dec->getDynamicClassID() != DecimalFormat::getStaticClassID()) {
+ DecimalFormat* dec = dynamic_cast<DecimalFormat*>(nf);
+ if (dec == NULL) {
errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat");
return;
}
_checklocs("DecimalFormatSymbols", req, valid, actual);
}
}
- delete dec;
+ delete nf;
#endif
// DateFormat, DateFormatSymbols
#if !UCONFIG_NO_FORMATTING
req = "de_CH_LUCERNE";
- SimpleDateFormat* dat = (SimpleDateFormat*)
+ DateFormat* df =
DateFormat::createDateInstance(DateFormat::kDefault,
Locale::createFromName(req));
- if (dat == 0){
+ if (df == 0){
dataerrln("Error calling DateFormat::createDateInstance()");
} else {
- if (dat->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) {
- errln("FAIL: NumberFormat::createInstance does not return a DecimalFormat");
+ SimpleDateFormat* dat = dynamic_cast<SimpleDateFormat*>(df);
+ if (dat == NULL) {
+ errln("FAIL: DateFormat::createInstance does not return a SimpleDateFormat");
return;
}
valid = dat->getLocale(ULOC_VALID_LOCALE, ec);
_checklocs("DateFormatSymbols", req, valid, actual);
}
}
- delete dat;
+ delete df;
#endif
// BreakIterator
reqLoc = Locale::createFromName(req);
BreakIterator* brk = BreakIterator::createWordInstance(reqLoc, ec);
if (U_FAILURE(ec)) {
- errln("FAIL: BreakIterator::createWordInstance failed");
+ dataerrln("FAIL: BreakIterator::createWordInstance failed - %s", u_errorName(ec));
} else {
valid = brk->getLocale(ULOC_VALID_LOCALE, ec);
actual = brk->getLocale(ULOC_ACTUAL_LOCALE, ec);
reqLoc = Locale::createFromName(req);
Collator* coll = Collator::createInstance(reqLoc, ec);
if (U_FAILURE(ec)) {
- errln("FAIL: Collator::createInstance failed");
+ dataerrln("FAIL: Collator::createInstance failed - %s", u_errorName(ec));
} else {
valid = coll->getLocale(ULOC_VALID_LOCALE, ec);
actual = coll->getLocale(ULOC_ACTUAL_LOCALE, ec);
const char *getNameID; /* expected getName() result */
const char *canonicalID; /* expected canonicalize() result */
} testCases[] = {
+ { "", "", "en_US_POSIX" },
+ { "C", "c", "en_US_POSIX" },
+ { "POSIX", "posix", "en_US_POSIX" },
{ "ca_ES_PREEURO-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage",
"ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE",
"ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"},
// Cycle through historical currencies
date = (UDate)-630720000000.0; // pre 1961 - no currency defined
- index = ucurr_countCurrencies("eo_AM", date, &status);
+ index = ucurr_countCurrencies("eo_AM", date, &status);
if (index != 0)
{
- errln("FAIL: didn't return 0 for eo_AM");
+ errcheckln(status, "FAIL: didn't return 0 for eo_AM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_AM didn't return NULL");
+ errcheckln(status, "FAIL: eo_AM didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
date = (UDate)0.0; // 1970 - one currency defined
- index = ucurr_countCurrencies("eo_AM", date, &status);
+ index = ucurr_countCurrencies("eo_AM", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AM");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("SUR");
if (resultStr != tempStr) {
- errln("FAIL: didn't return SUR for eo_AM");
+ errcheckln(status, "FAIL: didn't return SUR for eo_AM - %s", u_errorName(status));
}
date = (UDate)693792000000.0; // 1992 - one currency defined
index = ucurr_countCurrencies("eo_AM", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AM");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("RUR");
if (resultStr != tempStr) {
- errln("FAIL: didn't return RUR for eo_AM");
+ errcheckln(status, "FAIL: didn't return RUR for eo_AM - %s", u_errorName(status));
}
date = (UDate)977616000000.0; // post 1993 - one currency defined
index = ucurr_countCurrencies("eo_AM", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AM");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AM", date, index, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AMD");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AMD for eo_AM");
+ errcheckln(status, "FAIL: didn't return AMD for eo_AM - %s", u_errorName(status));
}
// Locale AD has multiple currencies at once
index = ucurr_countCurrencies("eo_AD", date, &status);
if (index != 4)
{
- errln("FAIL: didn't return 4 for eo_AD");
+ errcheckln(status, "FAIL: didn't return 4 for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("EUR");
if (resultStr != tempStr) {
- errln("FAIL: didn't return EUR for eo_AD");
+ errcheckln(status, "FAIL: didn't return EUR for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ESP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ESP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 3, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("FRF");
if (resultStr != tempStr) {
- errln("FAIL: didn't return FRF for eo_AD");
+ errcheckln(status, "FAIL: didn't return FRF for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 4, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ADP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ADP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ADP for eo_AD - %s", u_errorName(status));
}
date = (UDate)0.0; // year 1970
index = ucurr_countCurrencies("eo_AD", date, &status);
if (index != 3)
{
- errln("FAIL: didn't return 3 for eo_AD");
+ errcheckln(status, "FAIL: didn't return 3 for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ESP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ESP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("FRF");
if (resultStr != tempStr) {
- errln("FAIL: didn't return FRF for eo_AD");
+ errcheckln(status, "FAIL: didn't return FRF for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 3, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ADP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ADP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ADP for eo_AD - %s", u_errorName(status));
}
date = (UDate)-630720000000.0; // year 1950
index = ucurr_countCurrencies("eo_AD", date, &status);
if (index != 2)
{
- errln("FAIL: didn't return 2 for eo_AD");
+ errcheckln(status, "FAIL: didn't return 2 for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ESP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ESP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ADP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ADP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ADP for eo_AD - %s", u_errorName(status));
}
date = (UDate)-2207520000000.0; // year 1900
index = ucurr_countCurrencies("eo_AD", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AD");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AD - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AD", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("ESP");
if (resultStr != tempStr) {
- errln("FAIL: didn't return ESP for eo_AD");
+ errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
}
// Locale UA has gap between years 1994 - 1996
index = ucurr_countCurrencies("eo_UA", date, &status);
if (index != 0)
{
- errln("FAIL: didn't return 0 for eo_UA");
+ errcheckln(status, "FAIL: didn't return 0 for eo_UA - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_UA", date, index, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_UA didn't return NULL");
+ errcheckln(status, "FAIL: eo_UA didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
// Test index bounds
resLen = ucurr_forLocaleAndDate("eo_UA", date, 100, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_UA didn't return NULL");
+ errcheckln(status, "FAIL: eo_UA didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
resLen = ucurr_forLocaleAndDate("eo_UA", date, 0, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_UA didn't return NULL");
+ errcheckln(status, "FAIL: eo_UA didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
index = ucurr_countCurrencies("eo_QQ", date, &status);
if (index != 0)
{
- errln("FAIL: didn't return 0 for eo_QQ");
+ errcheckln(status, "FAIL: didn't return 0 for eo_QQ - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
resLen = ucurr_forLocaleAndDate("eo_QQ", date, 1, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_QQ didn't return NULL");
+ errcheckln(status, "FAIL: eo_QQ didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
resLen = ucurr_forLocaleAndDate("eo_QQ", date, 0, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_QQ didn't return NULL");
+ errcheckln(status, "FAIL: eo_QQ didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
index = ucurr_countCurrencies("eo_AO", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AO");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AOA");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AOA for eo_AO");
+ errcheckln(status, "FAIL: didn't return AOA for eo_AO - %s", u_errorName(status));
}
date = (UDate)819936000000.0; // 1996 - 2 currencies
index = ucurr_countCurrencies("eo_AO", date, &status);
if (index != 2)
{
- errln("FAIL: didn't return 1 for eo_AO");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AOR");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AOR for eo_AO");
+ errcheckln(status, "FAIL: didn't return AOR for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AON");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AON for eo_AO");
+ errcheckln(status, "FAIL: didn't return AON for eo_AO - %s", u_errorName(status));
}
date = (UDate)662256000000.0; // 1991 - 2 currencies
index = ucurr_countCurrencies("eo_AO", date, &status);
if (index != 2)
{
- errln("FAIL: didn't return 1 for eo_AO");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AON");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AON for eo_AO");
+ errcheckln(status, "FAIL: didn't return AON for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AOK");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AOK for eo_AO");
+ errcheckln(status, "FAIL: didn't return AOK for eo_AO - %s", u_errorName(status));
}
date = (UDate)315360000000.0; // 1980 - one currency
index = ucurr_countCurrencies("eo_AO", date, &status);
if (index != 1)
{
- errln("FAIL: didn't return 1 for eo_AO");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("AOK");
if (resultStr != tempStr) {
- errln("FAIL: didn't return AOK for eo_AO");
+ errcheckln(status, "FAIL: didn't return AOK for eo_AO - %s", u_errorName(status));
}
date = (UDate)0.0; // 1970 - no currencies
index = ucurr_countCurrencies("eo_AO", date, &status);
if (index != 0)
{
- errln("FAIL: didn't return 1 for eo_AO");
+ errcheckln(status, "FAIL: didn't return 1 for eo_AO - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_AO", date, 1, TMP, 4, &status);
if (resLen != 0) {
- errln("FAIL: eo_AO didn't return NULL");
+ errcheckln(status, "FAIL: eo_AO didn't return NULL - %s", u_errorName(status));
}
status = U_ZERO_ERROR;
index = ucurr_countCurrencies("eo_DE@currency=DEM", date, &status);
if (index != 2)
{
- errln("FAIL: didn't return 2 for eo_DE@currency=DEM");
+ errcheckln(status, "FAIL: didn't return 2 for eo_DE@currency=DEM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_DE@currency=DEM", date, 1, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("EUR");
if (resultStr != tempStr) {
- errln("FAIL: didn't return EUR for eo_DE@currency=DEM");
+ errcheckln(status, "FAIL: didn't return EUR for eo_DE@currency=DEM - %s", u_errorName(status));
}
resLen = ucurr_forLocaleAndDate("eo_DE@currency=DEM", date, 2, TMP, 4, &status);
tempStr.setTo(TMP);
resultStr.setTo("DEM");
if (resultStr != tempStr) {
- errln("FAIL: didn't return DEM for eo_DE@currency=DEM");
+ errcheckln(status, "FAIL: didn't return DEM for eo_DE@currency=DEM - %s", u_errorName(status));
}
// Test Euro Support
ucurr_forLocaleAndDate("en_US", date, 1, TMP, 4, &status);
if (u_strcmp(USD, TMP) != 0) {
- errln("Fail: en_US didn't return USD");
+ errcheckln(status, "Fail: en_US didn't return USD - %s", u_errorName(status));
}
ucurr_forLocaleAndDate("en_US_PREEURO", date, 1, TMP, 4, &status);
if (u_strcmp(USD, TMP) != 0) {
- errln("Fail: en_US_PREEURO didn't fallback to en_US");
+ errcheckln(status, "Fail: en_US_PREEURO didn't fallback to en_US - %s", u_errorName(status));
}
ucurr_forLocaleAndDate("en_US_Q", date, 1, TMP, 4, &status);
if (u_strcmp(USD, TMP) != 0) {
- errln("Fail: en_US_Q didn't fallback to en_US");
+ errcheckln(status, "Fail: en_US_Q didn't fallback to en_US - %s", u_errorName(status));
}
status = U_ZERO_ERROR; // reset
#endif
}
+
+void LocaleTest::TestGetVariantWithKeywords(void)
+{
+ Locale l("en_US_VALLEY@foo=value");
+ const char *variant = l.getVariant();
+ logln(variant);
+ test_assert(strcmp("VALLEY", variant) == 0);
+
+ UErrorCode status = U_ZERO_ERROR;
+ char buffer[50];
+ int32_t len = l.getKeywordValue("foo", buffer, 50, status);
+ buffer[len] = '\0';
+ test_assert(strcmp("value", buffer) == 0);
+}