]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/loctest.cpp
ICU-491.11.3.tar.gz
[apple/icu.git] / icuSources / test / intltest / loctest.cpp
index 06264a7fba9ce63317bfeb1f6be2ab46f641f0c8..91e79f8d437d7f1d9395d0299c56a6aec01b6a22 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2006, International Business Machines Corporation and
+ * Copyright (c) 1997-2011, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
 #include "unicode/coll.h"
 #include "cstring.h"
 #include <stdio.h>
+#include <string.h>
+#include "putilimp.h"
+#include "unicode/ustring.h"
 
-const char* rawData[33][8] = {
+static const char* const rawData[33][8] = {
 
         // language code
         {   "en",   "fr",   "ca",   "el",   "no",   "it",   "xx",   "zh"  },
@@ -44,31 +47,31 @@ const char* rawData[33][8] = {
         // display name (English)
         // Updated no_NO_NY English display name for new pattern-based algorithm
         // (part of Euro support).
-        {   "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway, NY)", "Italian", "xx (YY)", "Chinese (Simplified Han, China)" },
+        {   "English (United States)", "French (France)", "Catalan (Spain)", "Greek (Greece)", "Norwegian (Norway, NY)", "Italian", "xx (YY)", "Chinese (Simplified, China)" },
 
         // display langage (French)
         {   "anglais",  "fran\\u00E7ais",   "catalan", "grec",    "norv\\u00E9gien",    "italien", "xx", "chinois" },
         // display script (French)
-        {   "",     "",     "",     "",     "",     "",     "",   "id\\u00E9ogrammes han (variante simplifi\\u00E9e)" },
+        {   "",     "",     "",     "",     "",     "",     "",   "chinois simplifi\\u00E9" },
         // display country (French)
         {   "\\u00C9tats-Unis",    "France",   "Espagne",  "Gr\\u00E8ce",   "Norv\\u00E8ge", "", "YY", "Chine" },
         // display variant (French)
         {   "",     "",     "",     "",     "NY",     "",     "",   "" },
         // display name (French)
         //{   "anglais (Etats-Unis)", "francais (France)", "catalan (Espagne)", "grec (Grece)", "norvegien (Norvege,Nynorsk)", "italien", "xx (YY)" },
-        {   "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)", "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "italien", "xx (YY)", "chinois (id\\u00E9ogrammes han (variante simplifi\\u00E9e), Chine)" }, // STILL not right
+        {   "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)", "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)", "italien", "xx (YY)", "chinois (id\\u00E9ogrammes han simplifi\\u00E9s, Chine)" }, // STILL not right
 
 
         /* display language (Catalan) */
-        {   "angl\\u00E8s", "franc\\u00E8s", "catal\\u00E0", "grec",  "noruec", "itali\\u00E0", "", "xin\\u00E9s" },
+        {   "angl\\u00E8s", "franc\\u00E8s", "catal\\u00E0", "grec",  "noruec", "itali\\u00E0", "", "xin\\u00E8s" },
         /* display script (Catalan) */
-        {   "", "", "",                    "", "", "", "", "Hans" },
+        {   "", "", "",                    "", "", "", "", "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\\u00E9s (Hans, Xina)" },
+        {   "angl\\u00E8s (Estats Units)", "franc\\u00E8s (Fran\\u00E7a)", "catal\\u00E0 (Espanya)", "grec (Gr\\u00E8cia)", "noruec (Noruega, NY)", "itali\\u00E0", "", "xin\\u00E8s (simplificat, Xina)" },
 
         // display langage (Greek)[actual values listed below]
         {   "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac",
@@ -81,9 +84,9 @@ const char* rawData[33][8] = {
             "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC"
         },
         // display script (Greek)
-        {   "", "", "", "", "", "", "", "Hans" },
+        {   "", "", "", "", "", "", "", "\\u0391\\u03c0\\u03bb\\u03bf\\u03c0\\u03bf\\u03b9\\u03b7\\u03bc\\u03ad\\u03bd\\u03b1 \\u03a7\\u03b1\\u03bd" },
         // 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",
@@ -95,14 +98,14 @@ const char* rawData[33][8] = {
         // 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 (Hans, \\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>)
@@ -210,10 +213,15 @@ void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c
         TESTCASE(23, TestParallelAPIValues);
         TESTCASE(24, TestKeywordVariants);
         TESTCASE(25, TestKeywordVariantParsing);
-        TESTCASE(26, TestGetBaseName);
-        TESTCASE(27, TestGetLocale);
-        TESTCASE(28, TestVariantWithOutCountry);
-        TESTCASE(29, TestCanonicalization);
+        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:
 
@@ -467,25 +475,40 @@ LocaleTest::TestDisplayNames()
     logln("  In locale = el_GR...");
     doTestDisplayNames(greek, DLANG_EL);
 
-    /* test that the default locale has a display name for its own language */
     UnicodeString s;
-    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");
-    }
+    UErrorCode status = U_ZERO_ERROR;
 
-    /*
-     * 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");
+#if !UCONFIG_NO_FORMATTING
+    DecimalFormatSymbols symb(status);
+    /* 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 */
+        /* 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) {
+                dataerrln("unable to get a display string for the language of the default locale [2]: " + s);
+            }
+        }
+    }
+    else {
+        logln("Default locale %s is unsupported by ICU\n", Locale().getName());
     }
     s.remove();
+#endif
+
     french.getDisplayCountry(s);
     if(s.isEmpty()) {
         errln("unable to get any default-locale display string for the country of fr_FR\n");
@@ -658,7 +681,7 @@ void LocaleTest::TestGetAvailableLocales()
     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;
@@ -761,15 +784,15 @@ void LocaleTest::doTestDisplayNames(Locale& displayLocale, int32_t compareIndex)
             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);
     }
 }
 
@@ -845,8 +868,8 @@ LocaleTest::TestGetLangsAndCountries()
       ;
 
     /* TODO: Change this test to be more like the cloctst version? */
-    if (testCount != 485)
-        errln("Expected getISOLanguages() to return 481 languages; it returned %d", testCount);
+    if (testCount != 536)
+        errln("Expected getISOLanguages() to return 536 languages; it returned %d", testCount);
     else {
         for (i = 0; i < 15; i++) {
             int32_t j;
@@ -876,8 +899,8 @@ LocaleTest::TestGetLangsAndCountries()
     for(testCount=0;test[testCount];testCount++)
       ;
 
-    if (testCount != 244){
-        errln("Expected getISOCountries to return 240 countries; it returned %d", testCount);
+    if (testCount != 246){
+        errln("Expected getISOCountries to return 246 countries; it returned %d", testCount);
     }else {
         for (i = 0; i < spot2Len; i++) {
             int32_t j;
@@ -893,8 +916,8 @@ LocaleTest::TestGetLangsAndCountries()
                 errln("Couldn't find " + spotCheck2[i] + " in country list.");
         }
     }
-        for (i = 0; i < testCount; i++) {
-      UnicodeString testee(test[i],"");
+    for (i = 0; i < testCount; i++) {
+        UnicodeString testee(test[i],"");
         UnicodeString uc(test[i],"");
         if (testee != uc.toUpper())
             errln(testee + " is not all upper case.");
@@ -903,6 +926,26 @@ LocaleTest::TestGetLangsAndCountries()
         if (i > 0 && testee.compare(test[i - 1]) <= 0)
             errln(testee + " appears in an out-of-order position in the list.");
     }
+
+    // This getAvailableLocales and getISO3Language
+    {
+        int32_t numOfLocales;
+        Locale  enLoc ("en");
+        const Locale *pLocales = Locale::getAvailableLocales(numOfLocales);
+
+        for (int i = 0; i < numOfLocales; i++) {
+            const Locale    &loc(pLocales[i]);
+            UnicodeString   name;
+            char        szName[200];
+
+            loc.getDisplayName (enLoc, name);
+            name.extract (0, 200, szName, sizeof(szName));
+
+            if (strlen(loc.getISO3Language()) == 0) {
+                errln("getISO3Language() returned an empty string for: " + name);
+            }
+        }
+    }
 }
 
 /**
@@ -924,7 +967,7 @@ LocaleTest::TestSimpleDisplayNames()
         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 + "\".");
     }
 }
@@ -1005,7 +1048,7 @@ LocaleTest::TestAtypicalLocales()
                                      "espagnol (Allemagne)",
                                     "Croatie",
                                     CharsToUnicodeString("Su\\u00E8de"),
-                                    CharsToUnicodeString("Dominicaine, r\\u00E9publique"),
+                                    CharsToUnicodeString("R\\u00E9publique dominicaine"),
                                     "Belgique" };
     UnicodeString spanishDisplayNames [] = {
                                      CharsToUnicodeString("alem\\u00E1n (Canad\\u00E1)"),
@@ -1039,7 +1082,7 @@ LocaleTest::TestAtypicalLocales()
         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()));
         }
@@ -1050,7 +1093,7 @@ LocaleTest::TestAtypicalLocales()
         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 + "\"");
     }
 
@@ -1059,7 +1102,7 @@ LocaleTest::TestAtypicalLocales()
         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 + "\"");
     }
 
@@ -1068,12 +1111,12 @@ LocaleTest::TestAtypicalLocales()
         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);
@@ -1097,7 +1140,7 @@ LocaleTest::TestThaiCurrencyFormat()
 
     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))
@@ -1192,27 +1235,27 @@ LocaleTest::TestEuroSupport()
     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)) {
@@ -1287,7 +1330,7 @@ LocaleTest::Test4139940()
     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;
@@ -1298,8 +1341,13 @@ LocaleTest::Test4139940()
     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 );
     }
 }
@@ -1332,7 +1380,7 @@ LocaleTest::Test4143951()
     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;
@@ -1417,10 +1465,10 @@ LocaleTest::Test4147552()
         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));
     }
@@ -1446,9 +1494,9 @@ LocaleTest::TestVariantParsing()
 
     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");
@@ -1504,7 +1552,7 @@ LocaleTest::Test4105828()
     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;
@@ -1538,7 +1586,7 @@ LocaleTest::TestSetIsBogus() {
 
 void
 LocaleTest::TestKeywordVariants(void) {
-    struct {
+    static const struct {
         const char *localeID;
         const char *expectedLocaleID;
         //const char *expectedLocaleIDNoKeywords;
@@ -1645,7 +1693,7 @@ LocaleTest::TestKeywordVariants(void) {
 
 void
 LocaleTest::TestKeywordVariantParsing(void) {
-    struct {
+    static const struct {
         const char *localeID;
         const char *keyword;
         const char *expectedValue;
@@ -1673,9 +1721,43 @@ LocaleTest::TestKeywordVariantParsing(void) {
     }
 }
 
+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) {
-    struct {
+    static const struct {
         const char *localeID;
         const char *baseName;
     } testCases[] = {
@@ -1743,7 +1825,7 @@ void LocaleTest::_checklocs(const char* label,
         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);
     }
@@ -1760,7 +1842,7 @@ void LocaleTest::TestGetLocale(void) {
     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);
@@ -1782,12 +1864,12 @@ void LocaleTest::TestGetLocale(void) {
     // 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;
         }
@@ -1812,20 +1894,21 @@ void LocaleTest::TestGetLocale(void) {
             _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);
@@ -1849,7 +1932,7 @@ void LocaleTest::TestGetLocale(void) {
             _checklocs("DateFormatSymbols", req, valid, actual);
         }        
     }
-    delete dat;
+    delete df;
 #endif
 
     // BreakIterator
@@ -1858,7 +1941,7 @@ void LocaleTest::TestGetLocale(void) {
     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);
@@ -1920,7 +2003,7 @@ void LocaleTest::TestGetLocale(void) {
     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);
@@ -1981,23 +2064,27 @@ void LocaleTest::TestGetLocale(void) {
 void LocaleTest::TestVariantWithOutCountry(void) {
     Locale loc("en","","POSIX");
     if (0 != strcmp(loc.getVariant(), "POSIX")) {
-        errln("FAIL: en__POSIX didn't get parsed correctly");
+        errln("FAIL: en__POSIX didn't get parsed correctly - name is %s - expected %s got %s", loc.getName(), "POSIX", loc.getVariant());
     }
     Locale loc2("en","","FOUR");
     if (0 != strcmp(loc2.getVariant(), "FOUR")) {
-        errln("FAIL: en__FOUR didn't get parsed correctly");
+        errln("FAIL: en__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc2.getName(), "FOUR", loc2.getVariant());
     }
     Locale loc3("en","Latn","","FOUR");
     if (0 != strcmp(loc3.getVariant(), "FOUR")) {
-        errln("FAIL: en_Latn__FOUR didn't get parsed correctly");
+        errln("FAIL: en_Latn__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc3.getName(), "FOUR", loc3.getVariant());
     }
     Locale loc4("","Latn","","FOUR");
     if (0 != strcmp(loc4.getVariant(), "FOUR")) {
-        errln("FAIL: _Latn__FOUR didn't get parsed correctly");
+        errln("FAIL: _Latn__FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc4.getName(), "FOUR", loc4.getVariant());
     }
     Locale loc5("","Latn","US","FOUR");
     if (0 != strcmp(loc5.getVariant(), "FOUR")) {
-        errln("FAIL: _Latn_US_FOUR didn't get parsed correctly");
+        errln("FAIL: _Latn_US_FOUR didn't get parsed correctly - name is %s - expected %s got %s", loc5.getName(), "FOUR", loc5.getVariant());
+    }
+    Locale loc6("de-1901");
+    if (0 != strcmp(loc6.getVariant(), "1901")) {
+        errln("FAIL: de-1901 didn't get parsed correctly - name is %s - expected %s got %s", loc6.getName(), "1901", loc6.getVariant());
     }
 }
 
@@ -2017,11 +2104,14 @@ static Locale _canonicalize(int32_t selector, /* 0==createFromName, 1==createCan
 
 void LocaleTest::TestCanonicalization(void)
 {
-    static struct {
+    static const struct {
         const char *localeID;    /* input */
         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"},
@@ -2051,7 +2141,7 @@ void LocaleTest::TestCanonicalization(void)
         { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" },
         { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" },
         { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" },
-        { "zh_TW_STROKE", "zh_TW_STROKE", "zh_Hant_TW@collation=stroke" },
+        { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" },
         { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" },
         { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" },
         { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" },
@@ -2064,12 +2154,12 @@ void LocaleTest::TestCanonicalization(void)
         { "qz-qz@Euro", "qz_QZ@Euro", "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */
         // NOTE: uloc_getName() works on en-BOONT, but Locale() parser considers it BOGUS
         // TODO: unify this behavior
-        { "en-BOONT", "BOGUS", "en__BOONT" }, /* registered name */
-        { "de-1901", "de_1901", "de__1901" }, /* registered name */
-        { "de-1906", "de_1906", "de__1906" }, /* registered name */
-        { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_CS" }, /* .NET name */
-        { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_CS" }, /* .NET name */
-        { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_CS" }, /* Linux name */
+        { "en-BOONT", "en_BOONT", "en_BOONT" }, /* registered name */
+        { "de-1901", "de_1901", "de_1901" }, /* registered name */
+        { "de-1906", "de_1906", "de_1906" }, /* registered name */
+        { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */
+        { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */
+        { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */
         { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */
         { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */
         { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */
@@ -2122,3 +2212,335 @@ void LocaleTest::TestCanonicalization(void)
         }
     }
 }
+
+void LocaleTest::TestCurrencyByDate(void)
+{
+#if !UCONFIG_NO_FORMATTING
+    UErrorCode status = U_ZERO_ERROR;
+    UDate date = uprv_getUTCtime();
+       UChar TMP[4];
+       int32_t index = 0;
+       int32_t resLen = 0;
+    UnicodeString tempStr, resultStr;
+
+       // Cycle through historical currencies
+    date = (UDate)-630720000000.0; // pre 1961 - no currency defined
+    index = ucurr_countCurrencies("eo_AM", date, &status);
+    if (index != 0)
+       {
+               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) {
+               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);
+    if (index != 1)
+       {
+               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) {
+        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)
+       {
+               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) {
+        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)
+       {
+               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) {
+        errcheckln(status, "FAIL: didn't return AMD for eo_AM - %s", u_errorName(status));
+    }
+
+    // Locale AD has multiple currencies at once
+       date = (UDate)977616000000.0; // year 2001
+       index = ucurr_countCurrencies("eo_AD", date, &status);
+    if (index != 4)
+       {
+               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) {
+        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) {
+        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) {
+        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) {
+        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)
+       {
+               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) {
+        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) {
+        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) {
+        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)
+       {
+               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) {
+        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) {
+        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)
+       {
+               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) {
+        errcheckln(status, "FAIL: didn't return ESP for eo_AD - %s", u_errorName(status));
+    }
+
+       // Locale UA has gap between years 1994 - 1996
+       date = (UDate)788400000000.0;
+       index = ucurr_countCurrencies("eo_UA", date, &status);
+    if (index != 0)
+       {
+               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) {
+               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) {
+               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) {
+               errcheckln(status, "FAIL: eo_UA didn't return NULL - %s", u_errorName(status));
+    }
+    status = U_ZERO_ERROR;
+
+       // Test for bogus locale
+       index = ucurr_countCurrencies("eo_QQ", date, &status);
+    if (index != 0)
+       {
+               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) {
+               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) {
+               errcheckln(status, "FAIL: eo_QQ didn't return NULL - %s", u_errorName(status));
+    }
+    status = U_ZERO_ERROR;
+
+    // Cycle through histrocial currencies
+       date = (UDate)977616000000.0; // 2001 - one currency
+       index = ucurr_countCurrencies("eo_AO", date, &status);
+    if (index != 1)
+       {
+               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) {
+        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)
+       {
+               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) {
+        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) {
+        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)
+       {
+               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) {
+        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) {
+        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)
+       {
+               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) {
+        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)
+       {
+               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) {
+               errcheckln(status, "FAIL: eo_AO didn't return NULL - %s", u_errorName(status));
+    }
+    status = U_ZERO_ERROR;
+
+    // Test with currency keyword override
+       date = (UDate)977616000000.0; // 2001 - two currencies
+       index = ucurr_countCurrencies("eo_DE@currency=DEM", date, &status);
+    if (index != 2)
+       {
+               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) {
+        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) {
+        errcheckln(status, "FAIL: didn't return DEM for eo_DE@currency=DEM - %s", u_errorName(status));
+    }
+
+    // Test Euro Support
+       status = U_ZERO_ERROR; // reset
+    date = uprv_getUTCtime();
+
+    UChar USD[4];
+    ucurr_forLocaleAndDate("en_US", date, 1, USD, 4, &status);
+    
+       UChar YEN[4];
+    ucurr_forLocaleAndDate("ja_JP", date, 1, YEN, 4, &status);
+
+    ucurr_forLocaleAndDate("en_US", date, 1, TMP, 4, &status);
+    if (u_strcmp(USD, TMP) != 0) {
+        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) {
+        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) {
+        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);
+}