]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/creststn.c
ICU-6.2.4.tar.gz
[apple/icu.git] / icuSources / test / cintltst / creststn.c
index 282fe93458d2468a719b854c6d2ac7b30c5be16d..6a3eaca19bdcdd405c04530e5a5654790d5a5645 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2003, International Business Machines Corporation and
+ * Copyright (c) 1997-2004, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
 #include <time.h>
 #include "unicode/utypes.h"
 #include "cintltst.h"
-#include "unicode/utypes.h"
+#include "unicode/putil.h"
 #include "unicode/ustring.h"
 #include "unicode/ucnv.h"
 #include "string.h"
 #include "cstring.h"
 #include "unicode/uchar.h"
-
+#include "ucol_imp.h"  /* for U_ICUDATA_COLL */
 #define RESTEST_HEAP_CHECK 0
 
 #include "unicode/uloc.h"
@@ -157,8 +157,10 @@ param[] =
 static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
 
 
-static void printUChars(UChar*);
+/*static void printUChars(UChar*);*/
 static void TestDecodedBundle(void);
+static void TestGetKeywordValues(void);
+static void TestGetFunctionalEquivalent(void);
 
 /***************************************************************************************/
 
@@ -172,6 +174,7 @@ void addNEWResourceBundleTest(TestNode** root)
     addTest(root, &TestResourceBundles,       "tsutil/creststn/TestResourceBundle");
     addTest(root, &TestFallback,              "tsutil/creststn/TestFallback");
     addTest(root, &TestGetVersion,            "tsutil/creststn/TestGetVersion");
+    addTest(root, &TestGetVersionColl,        "tsutil/creststn/TestGetVersionColl");
     addTest(root, &TestAliasConflict,         "tsutil/creststn/TestAliasConflict");
     addTest(root, &TestNewTypes,              "tsutil/creststn/TestNewTypes");
     addTest(root, &TestEmptyTypes,            "tsutil/creststn/TestEmptyTypes");
@@ -181,6 +184,9 @@ void addNEWResourceBundleTest(TestNode** root)
     addTest(root, &TestDecodedBundle,         "tsutil/creststn/TestDecodedBundle");
     addTest(root, &TestResourceLevelAliasing, "tsutil/creststn/TestResourceLevelAliasing");
     addTest(root, &TestDirectAccess,          "tsutil/creststn/TestDirectAccess"); 
+    addTest(root, &TestGetKeywordValues,      "tsutil/creststn/TestGetKeywordValues"); 
+    addTest(root, &TestGetFunctionalEquivalent,"tsutil/creststn/TestGetFunctionalEquivalent");
+    addTest(root, &TestJB3763,                "tsutil/creststn/TestJB3763");
 
 }
 
@@ -206,12 +212,12 @@ static const char* norwayLocales[] = {
     "nb"
 };
 
-static void checkStatus(UErrorCode expected, UErrorCode status) {
+static void checkStatus(int32_t line, UErrorCode expected, UErrorCode status) {
   if(U_FAILURE(status)) {
-    log_data_err("Resource not present, cannot test\n");
+    log_data_err("Resource not present, cannot test (%s:%d)\n", __FILE__, line);
   }
   if(status != expected) {
-    log_err("Expected error code %s, got error code %s\n", u_errorName(expected), u_errorName(status));
+    log_err("%s:%d: Expected error code %s, got error code %s\n", __FILE__, line, u_errorName(expected), u_errorName(status));
   }
 }
 
@@ -220,40 +226,80 @@ static void TestErrorCodes(void) {
 
   UResourceBundle *r = NULL, *r2 = NULL;
 
+  /* First check with ICUDATA */
   /* first bundle should return fallback warning */
-  r = ures_open(NULL, "sr_YU_VOJVODINA", &status);
-  checkStatus(U_USING_FALLBACK_WARNING, status);
+  r = ures_open(NULL, "ti_ER_ASSAB", &status);
+  checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
   ures_close(r);
 
   /* this bundle should return zero error, so it shouldn't change the status*/
   status = U_USING_DEFAULT_WARNING;
-  r = ures_open(NULL, "sr_YU", &status);
-  checkStatus(U_USING_DEFAULT_WARNING, status);
+  r = ures_open(NULL, "ti_ER", &status);
+  checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
 
   /* we look up the resource which is aliased, but it lives in fallback */
   if(U_SUCCESS(status) && r != NULL) {
     status = U_USING_DEFAULT_WARNING; 
-    r2 = ures_getByKey(r, "CollationElements", NULL, &status);
-    checkStatus(U_USING_FALLBACK_WARNING, status);
+    r2 = ures_getByKey(r, "Languages", NULL, &status);  /* languages of 'ti' aliases to 'am' */
+    checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
   } 
   ures_close(r);
 
   /* this bundle should return zero error, so it shouldn't change the status*/
   status = U_USING_DEFAULT_WARNING;
-  r = ures_open(NULL, "sr", &status);
-  checkStatus(U_USING_DEFAULT_WARNING, status);
+  r = ures_open(NULL, "ti", &status);
+  checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
 
   /* we look up the resource which is aliased and at our level */
   if(U_SUCCESS(status) && r != NULL) {
     status = U_USING_DEFAULT_WARNING; 
-    r2 = ures_getByKey(r, "CollationElements", r2, &status);
-    checkStatus(U_USING_DEFAULT_WARNING, status);
+    r2 = ures_getByKey(r, "Languages", r2, &status);
+    checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
   }
   ures_close(r);
 
   status = U_USING_FALLBACK_WARNING;
   r = ures_open(NULL, "nolocale", &status);
-  checkStatus(U_USING_DEFAULT_WARNING, status);
+  checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
+  ures_close(r);
+  ures_close(r2);
+
+  /** Now, with the collation bundle **/
+  
+  /* first bundle should return fallback warning */
+  r = ures_open(U_ICUDATA_COLL, "sr_YU_VOJVODINA", &status);
+  checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
+  ures_close(r);
+
+  /* this bundle should return zero error, so it shouldn't change the status*/
+  status = U_USING_FALLBACK_WARNING;
+  r = ures_open(U_ICUDATA_COLL, "sr", &status);
+  checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
+
+  /* we look up the resource which is aliased  */
+  if(U_SUCCESS(status) && r != NULL) {
+    status = U_USING_DEFAULT_WARNING; 
+    r2 = ures_getByKey(r, "collations", NULL, &status);
+    checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
+  } 
+  ures_close(r);
+
+  /* this bundle should return zero error, so it shouldn't change the status*/
+  status = U_USING_DEFAULT_WARNING;
+  r = ures_open(U_ICUDATA_COLL, "sr", &status);
+  checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
+
+  /* we look up the resource which is aliased and at our level */
+  if(U_SUCCESS(status) && r != NULL) {
+    status = U_USING_DEFAULT_WARNING; 
+    r2 = ures_getByKey(r, "collations", r2, &status);
+    checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
+  }
+  ures_close(r);
+
+  status = U_USING_FALLBACK_WARNING;
+  r = ures_open(U_ICUDATA_COLL, "nolocale", &status);
+  checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
   ures_close(r);
   ures_close(r2);
 }
@@ -511,7 +557,7 @@ static void TestNewTypes() {
         const UChar* str = ures_getStringByKey(theBundle,"testescape",&len,&status);
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         if(U_SUCCESS(status)){
-            u_charsToUChars(expect,uExpect,uprv_strlen(expect)+1);
+            u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
             if(u_strcmp(uExpect,str)){
                 log_err("Did not get the expected string for testescape\n");
             }
@@ -520,29 +566,43 @@ static void TestNewTypes() {
     /* this tests if unescaping works are expected */
     len=0;
     {
-        static const char pattern[] = "[ \\\\u0020 \\\\u00A0 \\\\u1680 \\\\u2000 \\\\u2001 \\\\u2002 \\\\u2003 \\\\u2004 \\\\u2005 \\\\u2006 \\\\u2007 "
+        char pattern[2048] = "";
+        int32_t patternLen;
+        UChar* expectedEscaped;
+        const UChar* got;
+        int32_t expectedLen;
+
+        /* This strcpy fixes compiler warnings about long strings */
+        strcpy(pattern, "[ \\\\u0020 \\\\u00A0 \\\\u1680 \\\\u2000 \\\\u2001 \\\\u2002 \\\\u2003 \\\\u2004 \\\\u2005 \\\\u2006 \\\\u2007 "
             "\\\\u2008 \\\\u2009 \\\\u200A \\u200B \\\\u202F \\u205F \\\\u3000 \\u0000-\\u001F \\u007F \\u0080-\\u009F "
             "\\\\u06DD \\\\u070F \\\\u180E \\\\u200C \\\\u200D \\\\u2028 \\\\u2029 \\\\u2060 \\\\u2061 \\\\u2062 \\\\u2063 "
             "\\\\u206A-\\\\u206F \\\\uFEFF \\\\uFFF9-\\uFFFC \\U0001D173-\\U0001D17A \\U000F0000-\\U000FFFFD "
             "\\U00100000-\\U0010FFFD \\uFDD0-\\uFDEF \\uFFFE-\\uFFFF \\U0001FFFE-\\U0001FFFF \\U0002FFFE-\\U0002FFFF "
+            );
+        strcat(pattern, 
             "\\U0003FFFE-\\U0003FFFF \\U0004FFFE-\\U0004FFFF \\U0005FFFE-\\U0005FFFF \\U0006FFFE-\\U0006FFFF "
             "\\U0007FFFE-\\U0007FFFF \\U0008FFFE-\\U0008FFFF \\U0009FFFE-\\U0009FFFF \\U000AFFFE-\\U000AFFFF "
             "\\U000BFFFE-\\U000BFFFF \\U000CFFFE-\\U000CFFFF \\U000DFFFE-\\U000DFFFF \\U000EFFFE-\\U000EFFFF "
             "\\U000FFFFE-\\U000FFFFF \\U0010FFFE-\\U0010FFFF \\uD800-\\uDFFF \\\\uFFF9 \\\\uFFFA \\\\uFFFB "
             "\\uFFFC \\uFFFD \\u2FF0-\\u2FFB \\u0340 \\u0341 \\\\u200E \\\\u200F \\\\u202A \\\\u202B \\\\u202C "
+            );
+        strcat(pattern, 
             "\\\\u202D \\\\u202E \\\\u206A \\\\u206B \\\\u206C \\\\u206D \\\\u206E \\\\u206F \\U000E0001 \\U000E0020-\\U000E007F "
-            "]";
-
-        int32_t patternLen = uprv_strlen(pattern);
-        UChar* expectedEscaped = (UChar*)malloc(U_SIZEOF_UCHAR * patternLen);
-        const UChar* got = ures_getStringByKey(theBundle,"test_unescaping",&len,&status);
-        int32_t expectedLen = u_unescape(pattern,expectedEscaped,patternLen);
-        if(u_strncmp(expectedEscaped,got,expectedLen)!=0 || expectedLen != len){
+            "]"
+            );
+
+        patternLen = (int32_t)uprv_strlen(pattern);
+        expectedEscaped = (UChar*)malloc(U_SIZEOF_UCHAR * patternLen);
+        got = ures_getStringByKey(theBundle,"test_unescaping",&len,&status);
+        expectedLen = u_unescape(pattern,expectedEscaped,patternLen);
+        if(got==NULL || u_strncmp(expectedEscaped,got,expectedLen)!=0 || expectedLen != len){
             log_err("genrb failed to unescape string\n");
         }
-        for(i=0;i<expectedLen;i++){
-            if(expectedEscaped[i] != got[i]){
-                log_verbose("Expected: 0x%04X Got: 0x%04X \n",expectedEscaped[i], got[i]);
+        if(got != NULL){
+            for(i=0;i<expectedLen;i++){
+                if(expectedEscaped[i] != got[i]){
+                    log_verbose("Expected: 0x%04X Got: 0x%04X \n",expectedEscaped[i], got[i]);
+                }
             }
         }
         free(expectedEscaped);
@@ -552,7 +612,7 @@ static void TestNewTypes() {
     {
         const UChar* str = ures_getStringByKey(theBundle,"test_underscores",&len,&status);
         expect ="test message ....";
-        u_charsToUChars(expect,uExpect,uprv_strlen(expect)+1);
+        u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         if(u_strcmp(uExpect,str)){
             log_err("Did not get the expected string for test_underscores.\n");
@@ -565,10 +625,11 @@ static void TestNewTypes() {
         int32_t strLength = 0;
         const UChar my[] = {0x0026,0x0027,0x0075,0x0027,0x0020,0x003d,0x0020,0x0027,0xff55,0x0027,0x0000}; /* &'\u0075' = '\uFF55' */
         status = U_ZERO_ERROR;
-        resB = ures_getByKey(theBundle,"CollationElements", resB,&status);
+        resB = ures_getByKey(theBundle, "collations", resB, &status);
+        resB = ures_getByKey(resB, "standard", resB, &status);
         str  = ures_getStringByKey(resB,"Sequence",&strLength,&status);
         if(!str || U_FAILURE(status)) {
-            log_data_err("Could not load CollationElements from theBundle: %s\n", u_errorName(status));
+            log_data_err("Could not load collations from theBundle: %s\n", u_errorName(status));
         } else if(u_strcmp(my,str) != 0){
             log_err("Did not get the expected string for escaped \\u0075\n");
         }
@@ -576,9 +637,9 @@ static void TestNewTypes() {
     }
     {
         const char *sourcePath = ctest_dataSrcDir();
-        int32_t srcPathLen = strlen(sourcePath);
+        int32_t srcPathLen = (int32_t)strlen(sourcePath);
         const char *deltaPath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
-        int32_t deltaPathLen = strlen(deltaPath);
+        int32_t deltaPathLen = (int32_t)strlen(deltaPath);
         char *testDataFileName = (char *) malloc( srcPathLen+ deltaPathLen + 50 );
         char *path = testDataFileName;
 
@@ -590,8 +651,8 @@ static void TestNewTypes() {
         {
             int32_t strLen =0;
             const UChar* str = ures_getStringByKey(theBundle, "testincludeUTF",&strLen,&status);
-            strcpy(path, "th18057.txt");
-            path[strlen("th18057.txt")]=0;
+            strcpy(path, "riwords.txt");
+            path[strlen("riwords.txt")]=0;
             if(U_FAILURE(status)){
                 log_err("Could not get testincludeUTF resource from testtypes bundle. Error: %s\n",u_errorName(status));
             }else{
@@ -604,10 +665,14 @@ static void TestNewTypes() {
                     if(U_SUCCESS(status)){
                         /* verify the contents */
                         if(strLen != len ){
-                            log_err("Did not get the expected len for th18057. Expected: %i , Got: %i\n", len ,strLen);
+                            log_err("Did not get the expected len for riwords. Expected: %i , Got: %i\n", len ,strLen);
+                        }
+                        /* test string termination */
+                        if(u_strlen(str) != strLen || str[strLen]!= 0 ){
+                            log_err("testinclude not null terminated!\n");
                         }
                         if(u_strncmp(str, buffer,strLen)!=0){
-                            log_err("Did not get the expected string from th18057. Include functionality failed for genrb.\n");
+                            log_err("Did not get the expected string from riwords. Include functionality failed for genrb.\n");
                         }
                     }else{
                         log_err("ucbuf failed to open %s. Error: %s\n", testDataFileName, u_errorName(status));
@@ -615,7 +680,7 @@ static void TestNewTypes() {
 
                     ucbuf_close(ucbuf);
                 }else{
-                    log_err("Could not get th18057.txt (path : %s). Error: %s\n",testDataFileName,u_errorName(status));
+                    log_err("Could not get riwords.txt (path : %s). Error: %s\n",testDataFileName,u_errorName(status));
                 }
             }
         }
@@ -829,7 +894,9 @@ static void TestEmptyBundle(){
 static void TestBinaryCollationData(){
     UErrorCode status=U_ZERO_ERROR;
     const char*      locale="te";
+#if !UCONFIG_NO_COLLATION 
     const char* testdatapath;
+#endif
     UResourceBundle *teRes = NULL;
     UResourceBundle *coll=NULL;
     UResourceBundle *binColl = NULL;
@@ -854,7 +921,8 @@ static void TestBinaryCollationData(){
         return;
     }
     status=U_ZERO_ERROR;
-    coll = ures_getByKey(teRes, "CollationElements", coll, &status);
+    coll = ures_getByKey(teRes, "collations", coll, &status);
+    coll = ures_getByKey(coll, "standard", coll, &status);
     if(U_SUCCESS(status)){
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         CONFIRM_INT_EQ(ures_getType(coll), URES_TABLE);
@@ -873,7 +941,7 @@ static void TestBinaryCollationData(){
         }
     }
     else{
-        log_err("ERROR: ures_getByKey(locale(te), CollationElements) failed\n");
+        log_err("ERROR: ures_getByKey(locale(te), collations) failed\n");
         return;
     }
     ures_close(binColl);
@@ -902,10 +970,10 @@ static void TestAPI() {
         log_err("Could not load testdata.dat %s \n",myErrorName(status));
         return;
     }
-    len =strlen(testdatapath);
+    len =(int32_t)strlen(testdatapath);
     utestdatapath = (UChar*) malloc((len+10)*sizeof(UChar));
 
-    u_charsToUChars(testdatapath, utestdatapath, strlen(testdatapath)+1);
+    u_charsToUChars(testdatapath, utestdatapath, (int32_t)strlen(testdatapath)+1);
     /*u_uastrcpy(utestdatapath, testdatapath);*/
 
     /*Test ures_openU */
@@ -941,7 +1009,7 @@ static void TestAPI() {
     }
     key=ures_getKey(teFillin);
     /*if(strcmp(key, "%%CollationBin") != 0){*/
-    if(strcmp(key, "CollationElements") != 0){
+    if(strcmp(key, "array_2d_in_Root_te") != 0){
         log_err("ERROR: ures_getNextResource() failed\n");
     }
 #endif
@@ -1033,7 +1101,7 @@ static void TestErrorConditions(){
         log_err("Could not load testdata.dat %s \n",myErrorName(status));
         return;
     }
-    len = strlen(testdatapath);
+    len = (int32_t)strlen(testdatapath);
     utestdatapath = (UChar*) malloc(sizeof(UChar) *(len+10));
     u_uastrcpy(utestdatapath, testdatapath);
   
@@ -1140,7 +1208,8 @@ static void TestErrorConditions(){
     } 
     /*Test ures_getBinary(0 status != U_ILLEGAL_ARGUMENT_ERROR*/
     status=U_ZERO_ERROR;
-    coll = ures_getByKey(teRes, "CollationElements", coll, &status);
+    coll = ures_getByKey(teRes, "collations", coll, &status);
+    coll = ures_getByKey(teRes, "standard", coll, &status);
     binColl=ures_getByKey(coll, "%%CollationBin", binColl, &status);
 
     status=U_ILLEGAL_ARGUMENT_ERROR;
@@ -1246,46 +1315,104 @@ static void TestGetVersion(){
     int i=0, j = 0;
     int locCount = uloc_countAvailable();
     const char *locName = "root";
+    
     log_verbose("The ures_getVersion tests begin : \n");
-  
+
     for(j = -1; j < locCount; j++) {
-      if(j >= 0) {
-        locName = uloc_getAvailable(j);
-      }
-      log_verbose("Testing version number for locale %s\n", locName);
-      resB = ures_open(NULL,locName, &status);
-      if (U_FAILURE(status)) {
-          log_err("Resource bundle creation for locale %s failed.: %s\n", locName, myErrorName(status));
-          ures_close(resB);
-          return;
-      }
-      ures_getVersion(resB, versionArray);
-      for (i=0; i<4; ++i) {
-          if (versionArray[i] < minVersionArray[i] ||
-              versionArray[i] > maxVersionArray[i])
-          {
-              log_err("Testing ures_getVersion() - unexpected result: %d.%d.%d.%d\n", 
-                  versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
-              break;
-          }
-      }
-      ures_close(resB);
+        if(j >= 0) {
+            locName = uloc_getAvailable(j);
+        }
+        log_verbose("Testing version number for locale %s\n", locName);
+        resB = ures_open(NULL,locName, &status);
+        if (U_FAILURE(status)) {
+            log_err("Resource bundle creation for locale %s failed.: %s\n", locName, myErrorName(status));
+            ures_close(resB);
+            return;
+        }
+        ures_getVersion(resB, versionArray);
+        for (i=0; i<4; ++i) {
+            if (versionArray[i] < minVersionArray[i] ||
+                versionArray[i] > maxVersionArray[i])
+            {
+                log_err("Testing ures_getVersion(%-5s) - unexpected result: %d.%d.%d.%d\n", 
+                    locName, versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
+                break;
+            }
+        }
+        ures_close(resB);
     }
 }
 
+
+static void TestGetVersionColl(){
+    UVersionInfo minVersionArray = {0x00, 0x00, 0x00, 0x00};
+    UVersionInfo maxVersionArray = {0x50, 0x80, 0xcf, 0xcf};
+    UVersionInfo versionArray;
+    UErrorCode status= U_ZERO_ERROR;
+    UResourceBundle* resB = NULL;   
+    UEnumeration *locs= NULL;
+    int i=0;
+    const char *locName = "root";
+    int32_t locLen;
+    const UChar* rules =NULL;
+    int32_t len = 0;
+    
+    log_verbose("The ures_getVersion(%s) tests begin : \n", U_ICUDATA_COLL);
+    locs = ures_openAvailableLocales(U_ICUDATA_COLL, &status);
+    if (U_FAILURE(status)) {
+       log_err("enumeration of %s failed.: %s\n", U_ICUDATA_COLL, myErrorName(status));
+       return;
+    }
+
+    do{
+        log_verbose("Testing version number for locale %s\n", locName);
+        resB = ures_open(U_ICUDATA_COLL,locName, &status);
+        if (U_FAILURE(status)) {
+            log_err("Resource bundle creation for locale %s:%s failed.: %s\n", U_ICUDATA_COLL, locName, myErrorName(status));
+            ures_close(resB);
+            return;
+        }
+        /* test NUL termination of UCARules */
+        rules = ures_getStringByKey(resB,"%%UCARULES",&len, &status);
+        if(!rules || U_FAILURE(status)) {
+          log_data_err("Could not load %%UCARULES for locale %s\n", locName);
+          continue;
+        }
+        if(u_strlen(rules) != len){
+            log_err("UCARules string not nul terminated! \n");
+        }
+        ures_getVersion(resB, versionArray);
+        for (i=0; i<4; ++i) {
+            if (versionArray[i] < minVersionArray[i] ||
+                versionArray[i] > maxVersionArray[i])
+            {
+                log_err("Testing ures_getVersion(%-5s) - unexpected result: %d.%d.%d.%d\n", 
+                    locName, versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
+                break;
+            }
+        }
+        ures_close(resB);
+    } while((locName = uenum_next(locs,&locLen,&status))&&U_SUCCESS(status));
+    
+    if(U_FAILURE(status)) {
+        log_err("Err %s testing Collation locales.\n", u_errorName(status));
+    }
+    uenum_close(locs);
+}
+
 static void TestResourceBundles()
 {
 
-  testTag("only_in_Root", TRUE, FALSE, FALSE);
-  testTag("in_Root_te", TRUE, TRUE, FALSE);
-  testTag("in_Root_te_te_IN", TRUE, TRUE, TRUE);
-  testTag("in_Root_te_IN", TRUE, FALSE, TRUE);
-  testTag("only_in_te", FALSE, TRUE, FALSE);
-  testTag("only_in_te_IN", FALSE, FALSE, TRUE);
-  testTag("in_te_te_IN", FALSE, TRUE, TRUE);
-  testTag("nonexistent", FALSE, FALSE, FALSE);
+    testTag("only_in_Root", TRUE, FALSE, FALSE);
+    testTag("in_Root_te", TRUE, TRUE, FALSE);
+    testTag("in_Root_te_te_IN", TRUE, TRUE, TRUE);
+    testTag("in_Root_te_IN", TRUE, FALSE, TRUE);
+    testTag("only_in_te", FALSE, TRUE, FALSE);
+    testTag("only_in_te_IN", FALSE, FALSE, TRUE);
+    testTag("in_te_te_IN", FALSE, TRUE, TRUE);
+    testTag("nonexistent", FALSE, FALSE, FALSE);
 
-  log_verbose("Passed:=  %d   Failed=   %d \n", pass, fail);
+    log_verbose("Passed:=  %d   Failed=   %d \n", pass, fail);
 
 }
 
@@ -1815,6 +1942,7 @@ static void TestFallback()
 {
     UErrorCode status = U_ZERO_ERROR;
     UResourceBundle *fr_FR = NULL;
+    UResourceBundle *subResource = NULL;
     const UChar *junk; /* ignored */
     int32_t resultLen;
 
@@ -1838,20 +1966,21 @@ static void TestFallback()
     status = U_ZERO_ERROR;
 
     /* OK first one. This should be a Default value. */
-    junk = ures_getStringByKey(fr_FR, "%%PREEURO", &resultLen, &status);
+    subResource = ures_getByKey(fr_FR, "MeasurementSystem", NULL, &status);
     if(status != U_USING_DEFAULT_WARNING)
     {
-        log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get %%PREEURO from fr_FR, got %s\n", 
+        log_data_err("Expected U_USING_DEFAULT_ERROR when trying to get CurrencyMap from fr_FR, got %s\n", 
             u_errorName(status));
     }
 
     status = U_ZERO_ERROR;
+    ures_close(subResource);
 
     /* and this is a Fallback, to fr */
-    junk = ures_getStringByKey(fr_FR, "DayNames", &resultLen, &status);
+    junk = ures_getStringByKey(fr_FR, "Countries", &resultLen, &status);
     if(status != U_USING_FALLBACK_WARNING)
     {
-        log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get DayNames from fr_FR, got %d\n", 
+        log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get Countries from fr_FR, got %d\n", 
             status);
     }
     
@@ -1863,18 +1992,20 @@ static void TestFallback()
     {
         UErrorCode err =U_ZERO_ERROR;
         UResourceBundle* myResB = ures_open(NULL,"no_NO_NY",&err);
-        UResourceBundle* resLocID = ures_getByKey(myResB, "LocaleID", NULL, &err);
+        UResourceBundle* resLocID = ures_getByKey(myResB, "Version", NULL, &err);
         UResourceBundle* tResB;
+        static const UChar versionStr[] = { 0x0031, 0x002E, 0x0032, 0};
+
         if(err != U_ZERO_ERROR){
-            log_data_err("Expected U_ZERO_ERROR when trying to test no_NO_NY aliased to nn_NO for LocaleID err=%s\n",u_errorName(err));
+            log_data_err("Expected U_ZERO_ERROR when trying to test no_NO_NY aliased to nn_NO for Version err=%s\n",u_errorName(err));
             return;
         }
-        if(ures_getInt(resLocID, &err) != 0x814){
-            log_data_err("Expected LocaleID=814, but got 0x%X\n", ures_getInt(resLocID, &err));
+        if(u_strcmp(ures_getString(resLocID, &resultLen, &err), versionStr) != 0){
+            log_data_err("ures_getString(resLocID, &resultLen, &err) returned an unexpected version value\n");
         }
-        tResB = ures_getByKey(myResB, "DayNames", NULL, &err);
+        tResB = ures_getByKey(myResB, "calendar", NULL, &err);
         if(err != U_USING_FALLBACK_WARNING){
-            log_err("Expected U_USING_FALLBACK_ERROR when trying to test no_NO_NY aliased with nn_NO_NY for DayNames err=%s\n",u_errorName(err));
+            log_err("Expected U_USING_FALLBACK_ERROR when trying to test no_NO_NY aliased with nn_NO_NY for calendar err=%s\n",u_errorName(err));
         }
         ures_close(resLocID);
         ures_close(myResB);
@@ -1884,259 +2015,482 @@ static void TestFallback()
 
 }
 
-static void printUChars(UChar* uchars){
-    int16_t i=0;
-    for(i=0; i<u_strlen(uchars); i++){
-        log_err("%04X ", *(uchars+i));
-    }
-}
+/* static void printUChars(UChar* uchars){
+/    int16_t i=0;
+/    for(i=0; i<u_strlen(uchars); i++){
+/        log_err("%04X ", *(uchars+i));
+/    }
+/ } */
 
 static void TestResourceLevelAliasing(void) {
-  UErrorCode status = U_ZERO_ERROR;
-  UResourceBundle *aliasB = NULL, *tb = NULL;
-  UResourceBundle *en = NULL, *uk = NULL, *testtypes = NULL;  
-  const char* testdatapath = NULL;
-  const UChar *string = NULL, *sequence = NULL;
-  const uint8_t *binary = NULL, *binSequence = NULL;
-  int32_t strLen = 0, seqLen = 0, binLen = 0, binSeqLen = 0;
-  testdatapath=loadTestData(&status);
-  if(U_FAILURE(status))
-  {
-      log_err("Could not load testdata.dat %s \n",myErrorName(status));
-      return;
-  }
-
-  aliasB = ures_open(testdatapath, "testaliases", &status);
+    UErrorCode status = U_ZERO_ERROR;
+    UResourceBundle *aliasB = NULL, *tb = NULL;
+    UResourceBundle *en = NULL, *uk = NULL, *testtypes = NULL;  
+    const char* testdatapath = NULL;
+    const UChar *string = NULL, *sequence = NULL;
+    const uint8_t *binary = NULL, *binSequence = NULL;
+    int32_t strLen = 0, seqLen = 0, binLen = 0, binSeqLen = 0;
+    char buffer[100];
+    char *s;
 
-  /* this should fail - circular alias */
-  tb = ures_getByKey(aliasB, "aaa", tb, &status);
-  if(status != U_TOO_MANY_ALIASES_ERROR) {
-    log_err("Failed to detect circular alias\n");
-  } else {
-    status = U_ZERO_ERROR;
-  }
-  tb = ures_getByKey(aliasB, "aab", tb, &status);
-  if(status != U_TOO_MANY_ALIASES_ERROR) {
-    log_err("Failed to detect circular alias\n");
-  } else {
-    status = U_ZERO_ERROR;
-  }
-  if(U_FAILURE(status) ) {
-    log_data_err("err loading tb resource\n");
-  }  else {
-    /* testing aliasing to a non existing resource */
-    tb = ures_getByKey(aliasB, "nonexisting", tb, &status);
-    if(status != U_MISSING_RESOURCE_ERROR) {
-      log_err("Managed to find an alias to non-existing resource\n");
-    } else {
-      status = U_ZERO_ERROR;
+    testdatapath=loadTestData(&status);
+    if(U_FAILURE(status))
+    {
+        log_err("Could not load testdata.dat %s \n",myErrorName(status));
+        return;
     }
     
+    aliasB = ures_open(testdatapath, "testaliases", &status);
+    
+    /* this should fail - circular alias */
+    tb = ures_getByKey(aliasB, "aaa", tb, &status);
+    if(status != U_TOO_MANY_ALIASES_ERROR) {
+        log_err("Failed to detect circular alias\n");
+    } else {
+        status = U_ZERO_ERROR;
+    }
+    tb = ures_getByKey(aliasB, "aab", tb, &status);
+    if(status != U_TOO_MANY_ALIASES_ERROR) {
+        log_err("Failed to detect circular alias\n");
+    } else {
+        status = U_ZERO_ERROR;
+    }
+    if(U_FAILURE(status) ) {
+        log_data_err("err loading tb resource\n");
+    }  else {
+      /* testing aliasing to a non existing resource */
+      tb = ures_getByKey(aliasB, "nonexisting", tb, &status);
+      if(status != U_MISSING_RESOURCE_ERROR) {
+        log_err("Managed to find an alias to non-existing resource\n");
+      } else {
+        status = U_ZERO_ERROR;
+      }
+      
+      /* testing referencing/composed alias */
+      uk = ures_findResource("ja/LocaleScript/2", uk, &status);
+      if((uk == NULL) || U_FAILURE(status)) {
+        log_err("Couldn't findResource('ja/LocaleScript/2') err %s\n", u_errorName(status));
+        goto cleanup;
+      } 
+      
+      sequence = ures_getString(uk, &seqLen, &status);
+      
+      tb = ures_getByKey(aliasB, "referencingalias", tb, &status);
+      string = ures_getString(tb, &strLen, &status);
+      
+      if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
+        log_err("Referencing alias didn't get the right string\n");
+      }
+      
+      string = ures_getStringByKey(aliasB, "referencingalias", &strLen, &status);
+      if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
+        log_err("Referencing alias didn't get the right string\n");
+      }
+      
+      checkStatus(__LINE__, U_ZERO_ERROR, status);
+      tb = ures_getByKey(aliasB, "LocaleScript", tb, &status);
+      checkStatus(__LINE__, U_ZERO_ERROR, status);
+      tb = ures_getByIndex(tb, 2, tb, &status);
+      checkStatus(__LINE__, U_ZERO_ERROR, status);
+      string = ures_getString(tb, &strLen, &status);
+      checkStatus(__LINE__, U_ZERO_ERROR, status);
+      
+      if(U_FAILURE(status)) {
+        log_err("%s trying to get string via separate getters\n", u_errorName(status));
+      } else if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
+        log_err("Referencing alias didn't get the right string\n");
+      }
+      
+      /* check whether the binary collation data is properly referenced by an alias */
+      uk = ures_findResource("th/BreakDictionaryData", uk, &status);
+      binSequence = ures_getBinary(uk, &binSeqLen, &status);
+      
+      tb = ures_getByKey(aliasB, "BreakDictionaryData", tb, &status);
+      binary = ures_getBinary(tb, &binLen, &status);
+      
+      if(U_FAILURE(status)) {
+        log_err("%s trying to read binary BreakDictionaryData\n");
+      } else if(binSeqLen != binLen || uprv_memcmp(binSequence, binary, binSeqLen) != 0) {
+        log_err("Referencing alias didn't get the right data\n");
+      }
+      
+      /* simple alias */
+      testtypes = ures_open(testdatapath, "testtypes", &status);
+      strcpy(buffer, "menu/file/open");
+      s = buffer;
+      uk = ures_findSubResource(testtypes, s, uk, &status);
+      sequence = ures_getString(uk, &seqLen, &status);
+      
+      tb = ures_getByKey(aliasB, "simplealias", tb, &status);
+      string = ures_getString(tb, &strLen, &status);
+      
+      if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
+        log_err("Referencing alias didn't get the right string\n");
+      }
+      
+      /* test indexed aliasing */
+      
+      tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
+      tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
+      string = ures_getString(tb, &strLen, &status);
+      
+      en = ures_findResource("en/zoneStrings/3/0", en, &status);
+      sequence = ures_getString(en, &seqLen, &status);
+      
+      if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
+        log_err("Referencing alias didn't get the right string\n");
+      }
+    }
+    /* test getting aliased string by index */
+    {
+        const char* keys[] = {
+                "KeyAlias0PST",
+                "KeyAlias1PacificStandardTime",
+                "KeyAlias2PDT",
+                "KeyAlias3LosAngeles"
+        };
+        
+        const char* strings[] = {
+                "America/Los_Angeles",
+                "Pacific Standard Time",
+                "PDT",
+                "Los Angeles",
+        };
+        UChar uBuffer[256];
+        const UChar* result;
+        int32_t uBufferLen = 0, resultLen = 0;
+        int32_t i = 0;
+        const char *key = NULL;
+        tb = ures_getByKey(aliasB, "testGetStringByKeyAliasing", tb, &status);
+        if(U_FAILURE(status)) {
+            log_err("Couldn't get testGetStringByKeyAliasing resource\n");
+        }
+        for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+            result = ures_getStringByKey(tb, keys[i], &resultLen, &status);
+            uBufferLen = u_unescape(strings[i], uBuffer, 256);
+            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+              log_err("Didn't get correct string while accesing alias table by key (%s)\n", keys[i]);
+            }
+        }
+        for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+            result = ures_getStringByIndex(tb, i, &resultLen, &status);
+            uBufferLen = u_unescape(strings[i], uBuffer, 256);
+            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+              log_err("Didn't get correct string while accesing alias table by index (%s)\n", strings[i]);
+            }
+        }
+        for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+            result = ures_getNextString(tb, &resultLen, &key, &status);
+            uBufferLen = u_unescape(strings[i], uBuffer, 256);
+            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+              log_err("Didn't get correct string while iterating over alias table (%s)\n", strings[i]);
+            }
+        }
+        tb = ures_getByKey(aliasB, "testGetStringByIndexAliasing", tb, &status);
+        if(U_FAILURE(status)) {
+            log_err("Couldn't get testGetStringByIndexAliasing resource\n");
+        }
+        for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+            result = ures_getStringByIndex(tb, i, &resultLen, &status);
+            uBufferLen = u_unescape(strings[i], uBuffer, 256);
+            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+              log_err("Didn't get correct string while accesing alias by index in an array (%s)\n", strings[i]);
+            }
+        }
+        for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+            result = ures_getNextString(tb, &resultLen, &key, &status);
+            uBufferLen = u_unescape(strings[i], uBuffer, 256);
+            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+              log_err("Didn't get correct string while iterating over aliases in an array (%s)\n", strings[i]);
+            }
+        }
+    }
+cleanup:
+    ures_close(aliasB);
+    ures_close(tb);
+    ures_close(en);
+    ures_close(uk);
+    ures_close(testtypes);
+}
 
-    /* testing referencing/composed alias */
-    uk = ures_findResource("uk/CollationElements/Sequence", uk, &status);
-    if((uk == NULL) || U_FAILURE(status)) {
-      log_err("Couldn't findResource('uk/collationelements/sequence') err %s\n", u_errorName(status));
-      return;
-    } 
-
-    sequence = ures_getString(uk, &seqLen, &status);
+static void TestDirectAccess(void) {
+    UErrorCode status = U_ZERO_ERROR;
+    UResourceBundle *t = NULL, *t2 = NULL;
+    const char* key = NULL;
     
-    tb = ures_getByKey(aliasB, "referencingalias", tb, &status);
-    string = ures_getString(tb, &strLen, &status);
+    char buffer[100];
+    char *s;
     
-    if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    t = ures_findResource("en/zoneStrings/3/2", t, &status);
+    if(U_FAILURE(status)) {
+        log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
+        status = U_ZERO_ERROR;
+    } else {
+        key = ures_getKey(t);
+        if(key != NULL) {
+            log_err("Got a strange key, expected NULL, got %s\n", key);
+        }
     }
-
-    string = ures_getStringByKey(aliasB, "referencingalias", &strLen, &status);
-    if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    t = ures_findResource("en/zoneStrings/3", t, &status);
+    if(U_FAILURE(status)) {
+        log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
+        status = U_ZERO_ERROR;
+    } else {
+        key = ures_getKey(t);
+        if(key != NULL) {
+            log_err("Got a strange key, expected NULL, got %s\n", key);
+        }
     }
-
-    tb = ures_getByKey(aliasB, "CollationElements", tb, &status);
-    tb = ures_getByKey(tb, "Sequence", tb, &status);
-    string = ures_getString(tb, &strLen, &status);
     
-    if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    t = ures_findResource("ja/LocaleScript", t, &status);
+    if(U_FAILURE(status)) {
+        log_err("Couldn't access keyed resource, error %s\n", u_errorName(status));
+        status = U_ZERO_ERROR;
+    } else {
+        key = ures_getKey(t);
+        if(strcmp(key, "LocaleScript")!=0) {
+            log_err("Got a strange key, expected 'LocaleScript', got %s\n", key);
+        }
     }
-
-#if !UCONFIG_NO_COLLATION
-
-    /*
-     * TODO for Vladimir: Make this test independent of UCONFIG_NO_xyz-switchable
-     * modules like collation, so that it can be tested even when collation
-     * data is not included in resource bundles.
-     */
-
-    /* check whether the binary collation data is properly referenced by an alias */
-    uk = ures_findResource("uk/CollationElements/%%CollationBin", uk, &status);
-    binSequence = ures_getBinary(uk, &binSeqLen, &status);
-
-    tb = ures_getByKey(aliasB, "CollationElements", tb, &status);
-    tb = ures_getByKey(tb, "%%CollationBin", tb, &status);
-    binary = ures_getBinary(tb, &binLen, &status);
-
-    if(binSeqLen != binLen || uprv_memcmp(binSequence, binary, binSeqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    
+    t2 = ures_open(NULL, "sr", &status);
+    if(U_FAILURE(status)) {
+        log_err("Couldn't open 'sr' resource bundle, error %s\n", u_errorName(status));
+        log_data_err("No 'sr', no test - you have bigger problems than testing direct access. "
+                     "You probably have no data! Aborting this test\n");
     }
-
-    /* simple alias */
-    testtypes = ures_open(testdatapath, "testtypes", &status);
-    uk = ures_findSubResource(testtypes, "menu/file/open", uk, &status);
-    sequence = ures_getString(uk, &seqLen, &status);
-
-    tb = ures_getByKey(aliasB, "simplealias", tb, &status);
-    string = ures_getString(tb, &strLen, &status);
-
-    if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    
+    if(U_SUCCESS(status)) {
+        strcpy(buffer, "Languages/hr");
+        s = buffer;
+        t = ures_findSubResource(t2, s, t, &status);
+        if(U_FAILURE(status)) {
+            log_err("Couldn't access keyed resource, error %s\n", u_errorName(status));
+            status = U_ZERO_ERROR;
+        } else {
+            key = ures_getKey(t);
+            if(strcmp(key, "hr")!=0) {
+                log_err("Got a strange key, expected 'hr', got %s\n", key);
+            }
+        }
     }
 
-    /* test indexed aliasing */
-
-    tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
-    tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
-    string = ures_getString(tb, &strLen, &status);
-
-    en = ures_findResource("en/zoneStrings/3/0", en, &status);
-    sequence = ures_getString(en, &seqLen, &status);
+    t = ures_findResource("root/calendar/islamic-civil/DateTimePatterns", t, &status);
+    if(U_SUCCESS(status)) {
+        log_err("This resource does not exist. How did it get here?\n");
+    }
+    status = U_ZERO_ERROR;
 
-    if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
-      log_err("Referencing alias didn't get the right string\n");
+    /* this one will freeze */
+    t = ures_findResource("root/calendar/islamic-civil/eras/abbreviated/0/mikimaus/pera", t, &status);
+    if(U_SUCCESS(status)) {
+        log_err("Second resource does not exist. How did it get here?\n");
     }
+    status = U_ZERO_ERROR;
 
-#endif
-  }
-  /* test getting aliased string by index */
-  {
-    const char* keys[] = {
-        "KeyAlias0PST",
-        "KeyAlias1PacificStandardTime",
-        "KeyAlias2PDT",
-        "KeyAlias3LosAngeles"
-    };
+    ures_close(t2);
+    t2 = ures_open(NULL, "he", &status);
+    t2 = ures_getByKeyWithFallback(t2, "calendar", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "DateTimePatterns", t2, &status);
+    if(U_SUCCESS(status)) {
+        log_err("This resource does not exist. How did it get here?\n");
+    }
+    status = U_ZERO_ERROR;
 
-    const char* strings[] = {
-      "PST",
-      "Pacific Standard Time",
-      "PDT",
-      "Los Angeles",
-    };
-    UChar buffer[256];
-    const UChar* result;
-    int32_t bufferLen = 0, resultLen = 0;
-    int32_t i = 0;
-    const char *key = NULL;
-    tb = ures_getByKey(aliasB, "testGetStringByKeyAliasing", tb, &status);
+    ures_close(t2);
+    t2 = ures_open(NULL, "he", &status);
+    /* George's fix */
+    t2 = ures_getByKeyWithFallback(t2, "calendar", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "eras", t2, &status);
     if(U_FAILURE(status)) {
-      log_err("Couldn't get testGetStringByKeyAliasing resource\n");
-    }
-    for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
-      result = ures_getStringByKey(tb, keys[i], &resultLen, &status);
-      bufferLen = u_unescape(strings[i], buffer, 256);
-      if(resultLen != bufferLen || u_strncmp(result, buffer, resultLen) != 0) {
-        log_err("Didn't get correct string while accesing alias table by key\n");
-      }
+        log_err("Didn't get Eras. I know they are there!\n");
     }
-    for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
-      result = ures_getStringByIndex(tb, i, &resultLen, &status);
-      bufferLen = u_unescape(strings[i], buffer, 256);
-      if(resultLen != bufferLen || u_strncmp(result, buffer, resultLen) != 0) {
-        log_err("Didn't get correct string while accesing alias table by index\n");
-      }
-    }
-    for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
-      result = ures_getNextString(tb, &resultLen, &key, &status);
-      bufferLen = u_unescape(strings[i], buffer, 256);
-      if(resultLen != bufferLen || u_strncmp(result, buffer, resultLen) != 0) {
-        log_err("Didn't get correct string while iterating over alias table\n");
-      }
+    status = U_ZERO_ERROR;
+
+    ures_close(t2);
+    t2 = ures_open(NULL, "root", &status);
+    t2 = ures_getByKeyWithFallback(t2, "calendar", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
+    t2 = ures_getByKeyWithFallback(t2, "DateTimePatterns", t2, &status);
+    if(U_SUCCESS(status)) {
+        log_err("This resource does not exist. How did it get here?\n");
     }
-    tb = ures_getByKey(aliasB, "testGetStringByIndexAliasing", tb, &status);
+    status = U_ZERO_ERROR;
+
+    ures_close(t2);
+    ures_close(t);
+}
+
+static void TestJB3763(void) {
+    /* Nasty bug prevented using parent as fill-in, since it would
+     * stomp the path information.
+     */
+    UResourceBundle *t = NULL;
+    UErrorCode status = U_ZERO_ERROR;
+    t = ures_open(NULL, "sr_Latn", &status);
+    t = ures_getByKeyWithFallback(t, "calendar", t, &status);
+    t = ures_getByKeyWithFallback(t, "gregorian", t, &status);
+    t = ures_getByKeyWithFallback(t, "AmPmMarkers", t, &status);
     if(U_FAILURE(status)) {
-      log_err("Couldn't get testGetStringByIndexAliasing resource\n");
-    }
-    for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
-      result = ures_getStringByIndex(tb, i, &resultLen, &status);
-      bufferLen = u_unescape(strings[i], buffer, 256);
-      if(resultLen != bufferLen || u_strncmp(result, buffer, resultLen) != 0) {
-        log_err("Didn't get correct string while accesing alias by index in an array\n");
-      }
-    }
-    for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
-      result = ures_getNextString(tb, &resultLen, &key, &status);
-      bufferLen = u_unescape(strings[i], buffer, 256);
-      if(resultLen != bufferLen || u_strncmp(result, buffer, resultLen) != 0) {
-        log_err("Didn't get correct string while iterating over aliases in an array\n");
-      }
+        log_err("This resource should be available?\n");
     }
-  }
+    status = U_ZERO_ERROR;
+
+    ures_close(t);
 
-  ures_close(aliasB);
-  ures_close(tb);
-  ures_close(en);
-  ures_close(uk);
-  ures_close(testtypes);
 }
 
-static void TestDirectAccess(void) {
+static void TestGetKeywordValues(void) {
+  UEnumeration *kwVals;
+  UBool foundStandard = FALSE;
   UErrorCode status = U_ZERO_ERROR;
-  UResourceBundle *t = NULL, *t2 = NULL;
-  const char* key = NULL;
+  const char *kw;
+#if !UCONFIG_NO_COLLATION
+  kwVals = ures_getKeywordValues( U_ICUDATA_COLL, "collations", &status);
 
-  t = ures_findResource("en/zoneStrings/3/2", t, &status);
-  if(U_FAILURE(status)) {
-    log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
-    status = U_ZERO_ERROR;
-  } else {
-    key = ures_getKey(t);
-    if(key != NULL) {
-      log_err("Got a strange key, expected NULL, got %s\n", key);
+  log_verbose("Testing getting collation keyword values:\n");
+  
+  while((kw=uenum_next(kwVals, NULL, &status))) {
+    log_verbose("  %s\n", kw);
+    if(!strcmp(kw,"standard")) {
+      if(foundStandard == FALSE) {
+        foundStandard = TRUE;
+      } else {
+        log_err("'standard' was found twice in the keyword list.\n");
+      }
     }
   }
-  t = ures_findResource("en/zoneStrings/3", t, &status);
+  if(foundStandard == FALSE) {
+    log_err("'standard' was not found in the keyword list.\n");
+  }
+  uenum_close(kwVals);
   if(U_FAILURE(status)) {
-    log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
-    status = U_ZERO_ERROR;
-  } else {
-    key = ures_getKey(t);
-    if(key != NULL) {
-      log_err("Got a strange key, expected NULL, got %s\n", key);
-    }
+    log_err("err %s getting collation values\n", u_errorName(status));
   }
+  status = U_ZERO_ERROR;
+#endif
+  foundStandard = FALSE;
+  kwVals = ures_getKeywordValues( "ICUDATA", "calendar", &status);
 
-  t = ures_findResource("sh/CollationElements/Sequence", t, &status);
-  if(U_FAILURE(status)) {
-    log_err("Couldn't access keyed resource, error %s\n", u_errorName(status));
-    status = U_ZERO_ERROR;
-  } else {
-    key = ures_getKey(t);
-    if(strcmp(key, "Sequence")!=0) {
-      log_err("Got a strange key, expected 'Sequence', got %s\n", key);
+  log_verbose("Testing getting calendar keyword values:\n");
+  
+  while((kw=uenum_next(kwVals, NULL, &status))) {
+    log_verbose("  %s\n", kw);
+    if(!strcmp(kw,"japanese")) {
+      if(foundStandard == FALSE) {
+        foundStandard = TRUE;
+      } else {
+        log_err("'japanese' was found twice in the calendar keyword list.\n");
+      }
     }
   }
-
-  t2 = ures_open(NULL, "sh", &status);
+  if(foundStandard == FALSE) {
+    log_err("'japanese' was not found in the calendar keyword list.\n");
+  }
+  uenum_close(kwVals);
   if(U_FAILURE(status)) {
-    log_err("Couldn't open 'sh' resource bundle, error %s\n", u_errorName(status));
-    log_data_err("No 'sh', no test - you have bigger problems than testing direct access. You probably have no data! Aborting this test\n");
+    log_err("err %s getting calendar values\n", u_errorName(status));
   }
+}
 
-  if(U_SUCCESS(status)) {
-    t = ures_findSubResource(t2, "CollationElements/Sequence", t, &status);
-    if(U_FAILURE(status)) {
-      log_err("Couldn't access keyed resource, error %s\n", u_errorName(status));
-      status = U_ZERO_ERROR;
+static void TestGetFunctionalEquivalentOf(const char *path, const char *resName, const char *keyword, UBool truncate, const char *testCases[]) {
+  int32_t i;
+  for(i=0;testCases[i];i+=3) {
+    UBool expectAvail = (testCases[i][0]=='t')?TRUE:FALSE;
+    UBool gotAvail = FALSE;
+    const char *inLocale = testCases[i+1];
+    const char *expectLocale = testCases[i+2];
+    char equivLocale[256];
+    int32_t len;
+    UErrorCode status = U_ZERO_ERROR;
+    log_verbose("%d:   %c      %s\texpect %s\n",i/3,  expectAvail?'t':'f', inLocale, expectLocale);
+    len = ures_getFunctionalEquivalent(equivLocale, 255, path,
+                                       resName, keyword, inLocale,
+                                       &gotAvail, truncate, &status);
+    if(U_FAILURE(status) || (len <= 0)) {
+      log_err("FAIL: got len %d, err %s  on #%d: %c\t%s\t%s\n",  
+            len, u_errorName(status),
+            i/3,expectAvail?'t':'f', inLocale, expectLocale);
     } else {
-      key = ures_getKey(t);
-      if(strcmp(key, "Sequence")!=0) {
-        log_err("Got a strange key, expected 'Sequence', got %s\n", key);
+      log_verbose("got:  %c   %s\n", expectAvail?'t':'f',equivLocale);
+      
+      if((gotAvail != expectAvail) || strcmp(equivLocale, expectLocale)) {
+      log_err("FAIL: got avail=%c, loc=%s but  expected #%d: %c\t%s\t-> loc=%s\n",  
+            gotAvail?'t':'f', equivLocale,
+            i/3,
+            expectAvail?'t':'f', inLocale, expectLocale);
+
       }
     }
   }
+}
 
-  ures_close(t);
-  ures_close(t2);
+static void TestGetFunctionalEquivalent(void) {
+  static const char *collCases[] = {
+   /*   avail   locale          equiv   */
+        "f",    "de_US_CALIFORNIA",            "de",
+        "t",    "zh_TW@collation=stroke",      "zh@collation=stroke",
+        "f",    "de_CN@collation=pinyin",      "de",
+        "t",    "zh@collation=pinyin",      "zh",
+        "t",    "zh_CN@collation=pinyin",      "zh", /* should be 'T' when validSubLocales works */
+        "t",    "zh_HK@collation=pinyin",      "zh",
+        "t",    "zh_HK@collation=stroke",      "zh@collation=stroke",
+        "t",    "zh_HK",  "zh@collation=stroke",
+        "t",    "zh_MO",  "zh@collation=stroke",
+        "t",    "zh_TW_STROKE",  "zh@collation=stroke",
+        "t",    "zh_TW_STROKE@collation=big5han",  "zh@collation=big5han",
+        "f",    "de_CN@calendar=japanese",     "de",
+        "t",    "de@calendar=japanese",        "de",
+        "t",    "zh_TW@collation=big5han",    "zh@collation=big5han",
+        "t",    "zh_TW@collation=gb2312han", "zh@collation=gb2312han",
+        "t",    "zh_CN@collation=big5han",    "zh@collation=big5han",
+        "t",    "zh_CN@collation=gb2312han", "zh@collation=gb2312han",
+        "t",    "zh@collation=big5han",       "zh@collation=big5han",
+        "t",    "zh@collation=gb2312han",    "zh@collation=gb2312han",
+        "t",    "hi_IN@collation=direct",      "hi@collation=direct",
+        "t",    "hi@collation=standard",      "hi",
+        "t",    "hi@collation=direct",      "hi@collation=direct",
+        "f",    "hi_AU@collation=direct;currency=CHF;calendar=buddhist",   "hi@collation=direct",
+        "f",    "hi_AU@collation=standard;currency=CHF;calendar=buddhist",   "hi",
+        NULL
+  };
+
+  static const char *calCases[] = {
+   /*   avail   locale                       equiv   */
+    "t",    "en_US",                         "en@calendar=gregorian",
+    "f",    "ja_JP_TOKYO",                   "ja@calendar=gregorian",
+    "f",    "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese",
+    "t",    "sr@calendar=gregorian", "sr@calendar=gregorian",
+    "t",    "en", "en@calendar=gregorian",
+    NULL
+  };
+  
+#if !UCONFIG_NO_COLLATION
+  TestGetFunctionalEquivalentOf(U_ICUDATA_COLL, "collations", "collation", TRUE, collCases);
+#endif
+  TestGetFunctionalEquivalentOf("ICUDATA", "calendar", "calendar", FALSE, calCases);
+
+#if !UCONFIG_NO_COLLATION
+  log_verbose("Testing error conditions:\n");
+  {
+    char equivLocale[256] = "???";
+    int32_t len;
+    UErrorCode status = U_ZERO_ERROR;
+    UBool gotAvail = FALSE;
+
+    len = ures_getFunctionalEquivalent(equivLocale, 255, U_ICUDATA_COLL,
+                                       "calendar", "calendar", "ar_EG@calendar=islamic", 
+                                       &gotAvail, FALSE, &status);
+
+    if(status == U_MISSING_RESOURCE_ERROR) {
+      log_verbose("PASS: Got expected U_MISSING_RESOURCE_ERROR\n");
+    } else {
+      log_err("ures_getFunctionalEquivalent  returned locale %s, avail %c, err %s, but expected U_MISSING_RESOURCE_ERROR \n",
+              equivLocale, gotAvail?'t':'f', u_errorName(status));
+    }
+  }
+#endif
 }
+