]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/creststn.c
ICU-8.11.tar.gz
[apple/icu.git] / icuSources / test / cintltst / creststn.c
index 6a3eaca19bdcdd405c04530e5a5654790d5a5645..f2cfa9cd72789897daa498872602b4dd16943dcf 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -25,6 +25,7 @@
 #include "cstring.h"
 #include "unicode/uchar.h"
 #include "ucol_imp.h"  /* for U_ICUDATA_COLL */
+#include "ubrkimpl.h" /* for U_ICUDATA_BRKITR */
 #define RESTEST_HEAP_CHECK 0
 
 #include "unicode/uloc.h"
@@ -127,7 +128,19 @@ typedef enum E_Where E_Where;
 #define CONFIRM_INT_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of %d\n",  action, actual, expected); }
 #define CONFIRM_INT_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of x >= %d\n",  action, actual, expected); }
 #define CONFIRM_INT_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); log_err("%s returned %d instead of x != %d\n",  action, actual, expected); }
-#define CONFIRM_ErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail();  log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); }
+/*#define CONFIRM_ErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail();  log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); } */
+static void 
+CONFIRM_ErrorCode(UErrorCode actual,UErrorCode expected) 
+{
+  if ((expected)==(actual)) 
+  { 
+    record_pass(); 
+  } else { 
+    record_fail();  
+    /*log_err("%s returned  %s  instead of %s\n", action, myErrorName(actual), myErrorName(expected)); */
+    log_err("returned  %s  instead of %s\n", myErrorName(actual), myErrorName(expected)); 
+  }
+}
 
 
 /* Array of our test objects */
@@ -161,6 +174,9 @@ static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
 static void TestDecodedBundle(void);
 static void TestGetKeywordValues(void);
 static void TestGetFunctionalEquivalent(void);
+static void TestCLDRStyleAliases(void);
+static void TestFallbackCodes(void);
+static void TestGetUTF8String(void);
 
 /***************************************************************************************/
 
@@ -171,7 +187,7 @@ void addNEWResourceBundleTest(TestNode** root)
     addTest(root, &TestErrorCodes,            "tsutil/creststn/TestErrorCodes");
     addTest(root, &TestEmptyBundle,           "tsutil/creststn/TestEmptyBundle");
     addTest(root, &TestConstruction1,         "tsutil/creststn/TestConstruction1");
-    addTest(root, &TestResourceBundles,       "tsutil/creststn/TestResourceBundle");
+    addTest(root, &TestResourceBundles,       "tsutil/creststn/TestResourceBundles");
     addTest(root, &TestFallback,              "tsutil/creststn/TestFallback");
     addTest(root, &TestGetVersion,            "tsutil/creststn/TestGetVersion");
     addTest(root, &TestGetVersionColl,        "tsutil/creststn/TestGetVersionColl");
@@ -187,7 +203,11 @@ void addNEWResourceBundleTest(TestNode** root)
     addTest(root, &TestGetKeywordValues,      "tsutil/creststn/TestGetKeywordValues"); 
     addTest(root, &TestGetFunctionalEquivalent,"tsutil/creststn/TestGetFunctionalEquivalent");
     addTest(root, &TestJB3763,                "tsutil/creststn/TestJB3763");
-
+    addTest(root, &TestXPath,                 "tsutil/creststn/TestXPath"); 
+    addTest(root, &TestCLDRStyleAliases,      "tsutil/creststn/TestCLDRStyleAliases");
+    addTest(root, &TestFallbackCodes,         "tsutil/creststn/TestFallbackCodes");    
+    addTest(root, &TestStackReuse,            "tsutil/creststn/TestStackReuse");
+    addTest(root, &TestGetUTF8String,         "tsutil/creststn/TestGetUTF8String");
 }
 
 
@@ -399,7 +419,7 @@ static void TestDecodedBundle(){
     int32_t num =0;
     const char *testdatapath = loadTestData(&error);
     resB = ures_open(testdatapath, "iscii", &error);
-    srcFromRes=ures_getStringByKey(resB,"str",&len,&error);
+    srcFromRes=tres_getString(resB,-1,"str",&len,&error);
     if(U_FAILURE(error)){
 #if UCONFIG_NO_LEGACY_CONVERSION
         log_info("Couldn't load iscii.bin from test data bundle, (because UCONFIG_NO_LEGACY_CONVERSION  is turned on)\n");
@@ -451,7 +471,7 @@ static void TestNewTypes() {
 
     theBundle = ures_open(testdatapath, "testtypes", &status);
 
-    empty = ures_getStringByKey(theBundle, "emptystring", &len, &status);
+    empty = tres_getString(theBundle, -1, "emptystring", &len, &status);
     if(empty && (*empty != 0 || len != 0)) {
       log_err("Empty string returned invalid value\n");
     }
@@ -468,7 +488,7 @@ static void TestNewTypes() {
     res = ures_getByKey(theBundle, "zerotest", res, &status);
     CONFIRM_ErrorCode(status, U_ZERO_ERROR);
     CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
-    zeroString=ures_getString(res, &len, &status);
+    zeroString=tres_getString(res, -1, NULL, &len, &status);
     if(U_SUCCESS(status)){
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         CONFIRM_INT_EQ(len, 7);
@@ -554,7 +574,7 @@ static void TestNewTypes() {
 
     /* this tests if escapes are preserved or not */
     {
-        const UChar* str = ures_getStringByKey(theBundle,"testescape",&len,&status);
+        const UChar* str = tres_getString(theBundle,-1,"testescape",&len,&status);
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         if(U_SUCCESS(status)){
             u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
@@ -593,7 +613,7 @@ static void TestNewTypes() {
 
         patternLen = (int32_t)uprv_strlen(pattern);
         expectedEscaped = (UChar*)malloc(U_SIZEOF_UCHAR * patternLen);
-        got = ures_getStringByKey(theBundle,"test_unescaping",&len,&status);
+        got = tres_getString(theBundle,-1,"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");
@@ -610,7 +630,7 @@ static void TestNewTypes() {
     }
     /* test for jitterbug#1435 */
     {
-        const UChar* str = ures_getStringByKey(theBundle,"test_underscores",&len,&status);
+        const UChar* str = tres_getString(theBundle,-1,"test_underscores",&len,&status);
         expect ="test message ....";
         u_charsToUChars(expect,uExpect,(int32_t)strlen(expect)+1);
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
@@ -619,6 +639,7 @@ static void TestNewTypes() {
         }
     }
     /* test for jitterbug#2626 */
+#if !UCONFIG_NO_COLLATION
     {
         UResourceBundle* resB = NULL;
         const UChar* str  = NULL;
@@ -627,7 +648,7 @@ static void TestNewTypes() {
         status = U_ZERO_ERROR;
         resB = ures_getByKey(theBundle, "collations", resB, &status);
         resB = ures_getByKey(resB, "standard", resB, &status);
-        str  = ures_getStringByKey(resB,"Sequence",&strLength,&status);
+        str  = tres_getString(resB,-1,"Sequence",&strLength,&status);
         if(!str || U_FAILURE(status)) {
             log_data_err("Could not load collations from theBundle: %s\n", u_errorName(status));
         } else if(u_strcmp(my,str) != 0){
@@ -635,6 +656,7 @@ static void TestNewTypes() {
         }
         ures_close(resB);
     }
+#endif
     {
         const char *sourcePath = ctest_dataSrcDir();
         int32_t srcPathLen = (int32_t)strlen(sourcePath);
@@ -650,7 +672,7 @@ static void TestNewTypes() {
         status = U_ZERO_ERROR;
         {
             int32_t strLen =0;
-            const UChar* str = ures_getStringByKey(theBundle, "testincludeUTF",&strLen,&status);
+            const UChar* str = tres_getString(theBundle, -1, "testincludeUTF",&strLen,&status);
             strcpy(path, "riwords.txt");
             path[strlen("riwords.txt")]=0;
             if(U_FAILURE(status)){
@@ -687,7 +709,7 @@ static void TestNewTypes() {
         status = U_ZERO_ERROR;
         {
             int32_t strLen =0;
-            const UChar* str = ures_getStringByKey(theBundle, "testinclude",&strLen,&status);
+            const UChar* str = tres_getString(theBundle, -1, "testinclude",&strLen,&status);
             strcpy(path, "translit_rules.txt");
             path[strlen("translit_rules.txt")]=0;
 
@@ -760,7 +782,7 @@ static void TestEmptyTypes() {
     res = ures_getByKey(theBundle, "emptyexplicitstring", res, &status);
     CONFIRM_ErrorCode(status, U_ZERO_ERROR);
     CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
-    zeroString=ures_getString(res, &len, &status);
+    zeroString=tres_getString(res, -1, NULL, &len, &status);
     if(U_SUCCESS(status)){
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         CONFIRM_INT_EQ(len, 0);
@@ -775,7 +797,7 @@ static void TestEmptyTypes() {
     res = ures_getByKey(theBundle, "emptystring", res, &status);
     CONFIRM_ErrorCode(status, U_ZERO_ERROR);
     CONFIRM_INT_EQ(ures_getType(res), URES_STRING);
-    zeroString=ures_getString(res, &len, &status);
+    zeroString=tres_getString(res, -1, NULL, &len, &status);
     if(U_SUCCESS(status)){
         CONFIRM_ErrorCode(status, U_ZERO_ERROR);
         CONFIRM_INT_EQ(len, 0);
@@ -958,6 +980,7 @@ static void TestAPI() {
     const char* testdatapath;
     UChar* utestdatapath=NULL;
     char convOutput[256];
+    UChar largeBuffer[1025];
     UResourceBundle *teRes = NULL;
     UResourceBundle *teFillin=NULL;
     UResourceBundle *teFillin2=NULL;
@@ -974,13 +997,43 @@ static void TestAPI() {
     utestdatapath = (UChar*) malloc((len+10)*sizeof(UChar));
 
     u_charsToUChars(testdatapath, utestdatapath, (int32_t)strlen(testdatapath)+1);
-    /*u_uastrcpy(utestdatapath, testdatapath);*/
+#if (U_FILE_SEP_CHAR != U_FILE_ALT_SEP_CHAR) && U_FILE_SEP_CHAR == '\\'
+    {
+        /* Convert all backslashes to forward slashes so that we can make sure that ures_openU
+           can handle invariant characters. */
+        UChar *backslash;
+        while ((backslash = u_strchr(utestdatapath, 0x005C))) {
+            *backslash = 0x002F;
+        }
+    }
+#endif
+
+    u_memset(largeBuffer, 0x0030, sizeof(largeBuffer)/sizeof(largeBuffer[0]));
+    largeBuffer[sizeof(largeBuffer)/sizeof(largeBuffer[0])-1] = 0;
 
     /*Test ures_openU */
 
+    status = U_ZERO_ERROR;
+    ures_close(ures_openU(largeBuffer, "root", &status));
+    if(status != U_ILLEGAL_ARGUMENT_ERROR){
+        log_err("ERROR: ures_openU() worked when the path is very large. It returned %s\n", myErrorName(status));
+    }
+
+    status = U_ZERO_ERROR;
+    ures_close(ures_openU(NULL, "root", &status));
+    if(U_FAILURE(status)){
+        log_err("ERROR: ures_openU() failed path = NULL with %s\n", myErrorName(status));
+    }
+
+    status = U_ILLEGAL_ARGUMENT_ERROR;
+    if(ures_openU(NULL, "root", &status) != NULL){
+        log_err("ERROR: ures_openU() worked with error status with %s\n", myErrorName(status));
+    }
+
+    status = U_ZERO_ERROR;
     teRes=ures_openU(utestdatapath, "te", &status);
     if(U_FAILURE(status)){
-        log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status));
+        log_err("ERROR: ures_openU() failed path =%s with %s\n", austrdup(utestdatapath), myErrorName(status));
         return;
     }
     /*Test ures_getLocale() */
@@ -1009,7 +1062,8 @@ static void TestAPI() {
     }
     key=ures_getKey(teFillin);
     /*if(strcmp(key, "%%CollationBin") != 0){*/
-    if(strcmp(key, "array_2d_in_Root_te") != 0){
+    /*if(strcmp(key, "array_2d_in_Root_te") != 0){*/ /* added "aliasClient" that goes first */
+    if(strcmp(key, "a") != 0){
         log_err("ERROR: ures_getNextResource() failed\n");
     }
 #endif
@@ -1020,7 +1074,7 @@ static void TestAPI() {
     if(U_FAILURE(status)){
         log_err("ERROR: ures_getByIndex on string resource failed\n");
     }
-    if(strcmp(u_austrcpy(convOutput, ures_getString(teFillin2, &len, &status)), "TE") != 0){
+    if(strcmp(u_austrcpy(convOutput, tres_getString(teFillin2, -1, NULL, &len, &status)), "TE") != 0){
         status=U_ZERO_ERROR;
         log_err("ERROR: ures_getByIndex on string resource fetched the key=%s, expected \"TE\" \n", austrdup(ures_getString(teFillin2, &len, &status)));
     }
@@ -1119,15 +1173,15 @@ static void TestErrorConditions(){
     log_verbose("Testing ures_openFillIn with UResourceBundle = NULL.....\n");
     status=U_ZERO_ERROR;
     ures_openFillIn(NULL, testdatapath, "te", &status);
-    if(status != U_INTERNAL_PROGRAM_ERROR){
-        log_err("ERROR: ures_openFillIn with UResourceBundle= NULL should fail.  Expected U_INTERNAL_PROGRAM_ERROR, Got: %s\n",
+    if(status != U_ILLEGAL_ARGUMENT_ERROR){
+        log_err("ERROR: ures_openFillIn with UResourceBundle= NULL should fail.  Expected U_ILLEGAL_ARGUMENT_ERROR, Got: %s\n",
                         myErrorName(status));
     }
     /*Test ures_getLocale() with status != U_ZERO_ERROR*/
     status=U_ZERO_ERROR;
     teRes=ures_openU(utestdatapath, "te", &status);
     if(U_FAILURE(status)){
-        log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status));
+        log_err("ERROR: ures_openU() failed path =%s with %s\n", austrdup(utestdatapath), myErrorName(status));
         return;
     }
     status=U_ILLEGAL_ARGUMENT_ERROR;
@@ -1373,9 +1427,9 @@ static void TestGetVersionColl(){
             return;
         }
         /* test NUL termination of UCARules */
-        rules = ures_getStringByKey(resB,"%%UCARULES",&len, &status);
+        rules = tres_getString(resB,-1,"UCARules",&len, &status);
         if(!rules || U_FAILURE(status)) {
-          log_data_err("Could not load %%UCARULES for locale %s\n", locName);
+          log_data_err("Could not load UCARules for locale %s\n", locName);
           continue;
         }
         if(u_strlen(rules) != len){
@@ -1466,8 +1520,8 @@ static void TestConstruction1()
         log_err("construction of %s did not succeed :  %s \n", locale, myErrorName(status));
         return;
     }
-    result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &len1, &err);
-    result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &len2, &err);
+    result1= tres_getString(test1, -1, "string_in_Root_te_te_IN", &len1, &err);
+    result2= tres_getString(test2, -1, "string_in_Root_te_te_IN", &len2, &err);
     if (U_FAILURE(err) || len1==0 || len2==0) {
         log_err("Something threw an error in TestConstruction(): %s\n", myErrorName(status));
         return;
@@ -1634,7 +1688,7 @@ static UBool testTag(const char* frag,
         status = U_ZERO_ERROR;
         len=0;
 
-        string=ures_getStringByKey(theBundle, tag, &len, &status);
+        string=tres_getString(theBundle, -1, tag, &len, &status);
         if(U_SUCCESS(status)) {
             expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 4));
             u_strcpy(expected_string,base);
@@ -1680,7 +1734,7 @@ static UBool testTag(const char* frag,
                 u_strcat(expected_string, element);
                 arrayItem1=ures_getNextResource(array, arrayItem1, &status);
                 if(U_SUCCESS(status)){
-                    CONFIRM_EQ(ures_getString(arrayItem1, &len, &status),expected_string);
+                    CONFIRM_EQ(tres_getString(arrayItem1, -1, NULL, &len, &status),expected_string);
                 }
             }
 
@@ -1772,7 +1826,7 @@ static UBool testTag(const char* frag,
                         u_strcat(expected_string, element);
                         arrayItem1=ures_getNextResource(tableRow, arrayItem1, &status);
                         if(U_SUCCESS(status)){
-                            const UChar *stringValue=ures_getString(arrayItem1, &len, &status);
+                            const UChar *stringValue=tres_getString(arrayItem1, -1, NULL, &len, &status);
                             CONFIRM_EQ(stringValue, expected_string);
                         }
                     }
@@ -1889,7 +1943,7 @@ static UBool testTag(const char* frag,
                     }else{
                         record_fail();
                     }
-                    t=(UChar*)ures_getString(tagelement, &len, &status);
+                    t=(UChar*)tres_getString(tagelement, -1, NULL, &len, &status);
                     if(!U_FAILURE(status)){
                         string=t;
                     }
@@ -1958,11 +2012,11 @@ static void TestFallback()
 
 
     /* clear it out..  just do some calls to get the gears turning */
-    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);
+    junk = tres_getString(fr_FR, -1, "LocaleID", &resultLen, &status);
     status = U_ZERO_ERROR;
-    junk = ures_getStringByKey(fr_FR, "LocaleString", &resultLen, &status);
+    junk = tres_getString(fr_FR, -1, "LocaleString", &resultLen, &status);
     status = U_ZERO_ERROR;
-    junk = ures_getStringByKey(fr_FR, "LocaleID", &resultLen, &status);
+    junk = tres_getString(fr_FR, -1, "LocaleID", &resultLen, &status);
     status = U_ZERO_ERROR;
 
     /* OK first one. This should be a Default value. */
@@ -1977,7 +2031,7 @@ static void TestFallback()
     ures_close(subResource);
 
     /* and this is a Fallback, to fr */
-    junk = ures_getStringByKey(fr_FR, "Countries", &resultLen, &status);
+    junk = tres_getString(fr_FR, -1, "Countries", &resultLen, &status);
     if(status != U_USING_FALLBACK_WARNING)
     {
         log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get Countries from fr_FR, got %d\n", 
@@ -1994,18 +2048,20 @@ static void TestFallback()
         UResourceBundle* myResB = ures_open(NULL,"no_NO_NY",&err);
         UResourceBundle* resLocID = ures_getByKey(myResB, "Version", NULL, &err);
         UResourceBundle* tResB;
-        static const UChar versionStr[] = { 0x0031, 0x002E, 0x0032, 0};
+        const UChar* version = NULL;
+        static const UChar versionStr[] = { 0x0031, 0x002E, 0x0033, 0x0037, 0x0000};
 
         if(err != U_ZERO_ERROR){
             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(u_strcmp(ures_getString(resLocID, &resultLen, &err), versionStr) != 0){
+        version = tres_getString(resLocID, -1, NULL, &resultLen, &err);
+        if(u_strcmp(version, versionStr) != 0){
             log_data_err("ures_getString(resLocID, &resultLen, &err) returned an unexpected version value\n");
         }
-        tResB = ures_getByKey(myResB, "calendar", NULL, &err);
+        tResB = ures_getByKey(myResB, "zoneStrings", 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 calendar 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 zoneStrings err=%s\n",u_errorName(err));
         }
         ures_close(resLocID);
         ures_close(myResB);
@@ -2028,8 +2084,8 @@ static void TestResourceLevelAliasing(void) {
     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;
+    /*const uint8_t *binary = NULL, *binSequence = NULL;*/
+    int32_t strLen = 0, seqLen = 0;/*, binLen = 0, binSeqLen = 0;*/
     char buffer[100];
     char *s;
 
@@ -2041,12 +2097,18 @@ static void TestResourceLevelAliasing(void) {
     }
     
     aliasB = ures_open(testdatapath, "testaliases", &status);
-    
+
+    if(U_FAILURE(status))
+    {
+        log_err("Could not load testaliases.res %s \n",myErrorName(status));
+        return;
+    }
     /* 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 {
+    }
+    else {
         status = U_ZERO_ERROR;
     }
     tb = ures_getByKey(aliasB, "aab", tb, &status);
@@ -2065,7 +2127,6 @@ static void TestResourceLevelAliasing(void) {
       } else {
         status = U_ZERO_ERROR;
       }
-      
       /* testing referencing/composed alias */
       uk = ures_findResource("ja/LocaleScript/2", uk, &status);
       if((uk == NULL) || U_FAILURE(status)) {
@@ -2073,16 +2134,16 @@ static void TestResourceLevelAliasing(void) {
         goto cleanup;
       } 
       
-      sequence = ures_getString(uk, &seqLen, &status);
+      sequence = tres_getString(uk, -1, NULL, &seqLen, &status);
       
       tb = ures_getByKey(aliasB, "referencingalias", tb, &status);
-      string = ures_getString(tb, &strLen, &status);
+      string = tres_getString(tb, -1, NULL, &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);
+      string = tres_getString(aliasB, -1, "referencingalias", &strLen, &status);
       if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
         log_err("Referencing alias didn't get the right string\n");
       }
@@ -2092,7 +2153,7 @@ static void TestResourceLevelAliasing(void) {
       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);
+      string = tres_getString(tb, -1, NULL, &strLen, &status);
       checkStatus(__LINE__, U_ZERO_ERROR, status);
       
       if(U_FAILURE(status)) {
@@ -2101,28 +2162,34 @@ static void TestResourceLevelAliasing(void) {
         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");
+
+      {
+            UResourceBundle* ja = ures_open(U_ICUDATA_BRKITR,"ja", &status);
+            const UChar *got = NULL, *exp=NULL;
+            int32_t gotLen = 0, expLen=0;
+            ja = ures_getByKey(ja, "boundaries", ja, &status);
+            exp = tres_getString(ja, -1, "word", &expLen, &status);
+              
+            tb = ures_getByKey(aliasB, "boundaries", tb, &status);
+            got = tres_getString(tb, -1, "word", &gotLen, &status);
+                
+            if(U_FAILURE(status)) {
+                log_err("%s trying to read str boundaries\n");
+            } else if(gotLen != expLen || u_strncmp(exp, got, gotLen) != 0) {
+                log_err("Referencing alias didn't get the right data\n");
+            }
+            ures_close(ja);
+            status = U_ZERO_ERROR;
       }
-      
       /* 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);
+      sequence = tres_getString(uk, -1, NULL, &seqLen, &status);
       
       tb = ures_getByKey(aliasB, "simplealias", tb, &status);
-      string = ures_getString(tb, &strLen, &status);
+      string = tres_getString(tb, -1, NULL, &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");
@@ -2132,10 +2199,10 @@ static void TestResourceLevelAliasing(void) {
       
       tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
       tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
-      string = ures_getString(tb, &strLen, &status);
+      string = tres_getString(tb, -1, NULL, &strLen, &status);
       
       en = ures_findResource("en/zoneStrings/3/0", en, &status);
-      sequence = ures_getString(en, &seqLen, &status);
+      sequence = tres_getString(en, -1, NULL, &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");
@@ -2166,23 +2233,35 @@ static void TestResourceLevelAliasing(void) {
             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);
+            result = tres_getString(tb, -1, keys[i], &resultLen, &status);
+            if(U_FAILURE(status)){
+                log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+                continue;
+            }
             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);
+            result = tres_getString(tb, i, NULL, &resultLen, &status); 
+            if(U_FAILURE(status)){
+                log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+                continue;
+            }
             uBufferLen = u_unescape(strings[i], uBuffer, 256);
-            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+            if(result==NULL || 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);
+            if(U_FAILURE(status)){
+                log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+                continue;
+            }
             uBufferLen = u_unescape(strings[i], uBuffer, 256);
-            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+            if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
               log_err("Didn't get correct string while iterating over alias table (%s)\n", strings[i]);
             }
         }
@@ -2191,20 +2270,35 @@ static void TestResourceLevelAliasing(void) {
             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);
+            result = tres_getString(tb, i, NULL, &resultLen, &status);
+            if(U_FAILURE(status)){
+                log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+                continue;
+            }
             uBufferLen = u_unescape(strings[i], uBuffer, 256);
-            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+            if(result==NULL || 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);
+            if(U_FAILURE(status)){
+                log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+                continue;
+            }
             uBufferLen = u_unescape(strings[i], uBuffer, 256);
-            if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+            if(result==NULL || 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]);
             }
         }
     }
+    tb = ures_getByKey(aliasB, "testAliasToTree", tb, &status);
+    if(U_FAILURE(status)){
+        log_err("Fetching the resource with key \"testAliasToTree\" failed. Error: %s\n", u_errorName(status));
+    }
+    if (strcmp(ures_getKey(tb), "collations") != 0) {
+        log_err("ures_getKey(aliasB) unexpectedly returned %s instead of \"collations\"\n", ures_getKey(tb));
+    }
 cleanup:
     ures_close(aliasB);
     ures_close(tb);
@@ -2220,8 +2314,13 @@ static void TestDirectAccess(void) {
     
     char buffer[100];
     char *s;
+    /*const char* testdatapath=loadTestData(&status);
+    if(U_FAILURE(status)){
+        log_err("Could not load testdata.dat %s \n",myErrorName(status));
+        return;
+    }*/
     
-    t = ures_findResource("en/zoneStrings/3/2", t, &status);
+    t = ures_findResource("/testdata/te/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;
@@ -2231,7 +2330,7 @@ static void TestDirectAccess(void) {
             log_err("Got a strange key, expected NULL, got %s\n", key);
         }
     }
-    t = ures_findResource("en/zoneStrings/3", t, &status);
+    t = ures_findResource("en/calendar/gregorian/DateTimePatterns/3", t, &status);
     if(U_FAILURE(status)) {
         log_err("Couldn't access indexed resource, error %s\n", u_errorName(status));
         status = U_ZERO_ERROR;
@@ -2275,7 +2374,7 @@ static void TestDirectAccess(void) {
         }
     }
 
-    t = ures_findResource("root/calendar/islamic-civil/DateTimePatterns", t, &status);
+    t = ures_findResource("root/calendar/islamic-civil/DateTime", t, &status);
     if(U_SUCCESS(status)) {
         log_err("This resource does not exist. How did it get here?\n");
     }
@@ -2292,7 +2391,7 @@ static void TestDirectAccess(void) {
     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);
+    t2 = ures_getByKeyWithFallback(t2, "DateTime", t2, &status);
     if(U_SUCCESS(status)) {
         log_err("This resource does not exist. How did it get here?\n");
     }
@@ -2313,7 +2412,7 @@ static void TestDirectAccess(void) {
     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);
+    t2 = ures_getByKeyWithFallback(t2, "DateTime", t2, &status);
     if(U_SUCCESS(status)) {
         log_err("This resource does not exist. How did it get here?\n");
     }
@@ -2417,10 +2516,10 @@ static void TestGetFunctionalEquivalentOf(const char *path, const char *resName,
       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);
+        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);
 
       }
     }
@@ -2454,13 +2553,21 @@ static void TestGetFunctionalEquivalent(void) {
         "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
+        "t",    "de_DE@collation=pinyin",      "de", /* bug 4582 tests */
+        "f",    "de_DE_BONN@collation=pinyin", "de",
+        "t",    "nl",                          "root",
+        "t",    "nl_NL",                       "root",
+        "f",    "nl_NL_EEXT",                  "root",
+        "t",    "nl@collation=stroke",         "root",
+        "t",    "nl_NL@collation=stroke",      "root",
+        "f",    "nl_NL_EEXT@collation=stroke", "root",
+       NULL
   };
 
   static const char *calCases[] = {
    /*   avail   locale                       equiv   */
-    "t",    "en_US",                         "en@calendar=gregorian",
-    "f",    "ja_JP_TOKYO",                   "ja@calendar=gregorian",
+    "t",    "en_US_POSIX",                   "en_US@calendar=gregorian",
+    "f",    "ja_JP_TOKYO",                   "ja_JP@calendar=gregorian",
     "f",    "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese",
     "t",    "sr@calendar=gregorian", "sr@calendar=gregorian",
     "t",    "en", "en@calendar=gregorian",
@@ -2494,3 +2601,329 @@ static void TestGetFunctionalEquivalent(void) {
 #endif
 }
 
+static void TestXPath(void) {
+    UErrorCode status = U_ZERO_ERROR;
+    UResourceBundle *rb = NULL, *alias = NULL;
+    int32_t len = 0;
+    const UChar* result = NULL;
+    const UChar expResult[] = { 0x0063, 0x006F, 0x0072, 0x0072, 0x0065, 0x0063, 0x0074, 0x0000 }; /* "correct" */
+    /*const UChar expResult[] = { 0x0074, 0x0065, 0x0069, 0x006E, 0x0064, 0x0065, 0x0073, 0x0074, 0x0000 }; *//*teindest*/
+    
+    const char *testdatapath=loadTestData(&status);
+    if(U_FAILURE(status))
+    {
+        log_err("Could not load testdata.dat %s \n",myErrorName(status));
+        return;
+    }
+    
+    log_verbose("Testing ures_open()......\n");
+
+    rb = ures_open(testdatapath, "te_IN", &status);
+    if(U_FAILURE(status)) {
+      log_err("Could not open te_IN (%s)\n", myErrorName(status));
+      return;
+    }
+    alias = ures_getByKey(rb, "rootAliasClient", alias, &status);
+    if(U_FAILURE(status)) {
+      log_err("Couldn't find the aliased resource (%s)\n", myErrorName(status));
+      ures_close(rb);
+      return;
+    }
+
+    result = tres_getString(alias, -1, NULL, &len, &status);
+    if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
+      log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
+    }
+
+    alias = ures_getByKey(rb, "aliasClient", alias, &status);
+    if(U_FAILURE(status)) {
+      log_err("Couldn't find the aliased resource (%s)\n", myErrorName(status));
+      ures_close(rb);
+      return;
+    }
+
+    result = tres_getString(alias, -1, NULL, &len, &status);
+    if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
+      log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
+    }
+
+    alias = ures_getByKey(rb, "nestedRootAliasClient", alias, &status);
+    if(U_FAILURE(status)) {
+      log_err("Couldn't find the aliased resource (%s)\n", myErrorName(status));
+      ures_close(rb);
+      return;
+    }
+
+    result = tres_getString(alias, -1, NULL, &len, &status);
+    if(U_FAILURE(status) || result == NULL || u_strcmp(result, expResult)) {
+      log_err("Couldn't get correct string value (%s)\n", myErrorName(status));
+    }
+
+    ures_close(alias);
+    ures_close(rb);
+}
+static void TestCLDRStyleAliases(void) {
+    UErrorCode status = U_ZERO_ERROR;
+    UResourceBundle *rb = NULL, *alias = NULL, *a=NULL;
+    int32_t i, len;
+    char resource[256];
+    const UChar *result = NULL;
+    UChar expected[256];
+    const char *expects[7] = { "", "a41", "a12", "a03", "ar4" };
+    const char *testdatapath=loadTestData(&status);
+    if(U_FAILURE(status)) {
+        log_err("Could not load testdata.dat %s \n",myErrorName(status));
+        return;
+    }
+    log_verbose("Testing CLDR style aliases......\n");
+
+    rb = ures_open(testdatapath, "te_IN_REVISED", &status);
+    if(U_FAILURE(status)) {
+      log_err("Could not open te_IN (%s)\n", myErrorName(status));
+      return;
+    }
+    alias = ures_getByKey(rb, "a", alias, &status);
+    if(U_FAILURE(status)) {
+      log_err("Couldn't find the aliased with name \"a\" resource (%s)\n", myErrorName(status));
+      ures_close(rb);
+      return;
+    }
+    for(i = 1; i < 5 ; i++) {
+      resource[0]='a';
+      resource[1]='0'+i;
+      resource[2]=0;
+      /* instead of sprintf(resource, "a%i", i); */
+      a = ures_getByKeyWithFallback(alias, resource, a, &status);
+      result = tres_getString(a, -1, NULL, &len, &status);
+      u_charsToUChars(expects[i], expected, strlen(expects[i])+1);
+      if(U_FAILURE(status) || !result || u_strcmp(result, expected)) {
+        log_err("CLDR style aliases failed resource with name \"%s\" resource, exp %s, got %S (%s)\n", resource, expects[i], result, myErrorName(status)); 
+        status = U_ZERO_ERROR;
+      }
+    }
+
+  ures_close(a);
+  ures_close(alias);
+  ures_close(rb);
+}
+
+static void TestFallbackCodes(void) {
+  UErrorCode status = U_ZERO_ERROR;
+  const char *testdatapath=loadTestData(&status);
+
+  UResourceBundle *res = ures_open(testdatapath, "te_IN", &status);
+
+  UResourceBundle *r = NULL, *fall = NULL;
+
+  r = ures_getByKey(res, "tagged_array_in_Root_te_te_IN", r, &status);
+
+  status = U_ZERO_ERROR;
+  fall = ures_getByKeyWithFallback(r, "tag2", fall, &status);
+
+  if(status != U_ZERO_ERROR) {
+    log_err("Expected error code to be U_ZERO_ERROR, got %s\n", u_errorName(status));
+    status = U_ZERO_ERROR;
+  }
+
+  fall = ures_getByKeyWithFallback(r, "tag7", fall, &status);
+
+  if(status != U_USING_FALLBACK_WARNING) {
+    log_err("Expected error code to be U_USING_FALLBACK_WARNING, got %s\n", u_errorName(status));
+  }
+  status = U_ZERO_ERROR;
+
+  fall = ures_getByKeyWithFallback(r, "tag1", fall, &status);
+
+  if(status != U_USING_DEFAULT_WARNING) {
+    log_err("Expected error code to be U_USING_DEFAULT_WARNING, got %s\n", u_errorName(status));
+  }
+  status = U_ZERO_ERROR;
+
+  ures_close(fall);
+  ures_close(r);
+  ures_close(res);
+}
+
+/* This test will crash if this doesn't work. Results don't need testing. */
+static void TestStackReuse(void) {
+    UResourceBundle table;
+    UErrorCode errorCode = U_ZERO_ERROR;
+    UResourceBundle *rb = ures_open(NULL, "en_US", &errorCode);
+
+    if(U_FAILURE(errorCode)) {
+        log_err("Could not load en_US locale. status=%s\n",myErrorName(errorCode));
+        return;
+    }
+    ures_initStackObject(&table);
+    ures_getByKeyWithFallback(rb, "Types", &table, &errorCode);
+    ures_getByKeyWithFallback(&table, "collation", &table, &errorCode);
+    ures_close(rb);
+    ures_close(&table);
+}
+
+/* Test ures_getUTF8StringXYZ() --------------------------------------------- */
+
+/*
+ * Replace most ures_getStringXYZ() with this function which wraps the
+ * desired call and also calls the UTF-8 variant and checks that it works.
+ */
+extern const UChar *
+tres_getString(const UResourceBundle *resB,
+               int32_t index, const char *key,
+               int32_t *length,
+               UErrorCode *status) {
+    char buffer8[16];
+    char *p8;
+    const UChar *s16;
+    const char *s8;
+    UChar32 c16, c8;
+    int32_t length16, length8, i16, i8;
+    UBool forceCopy;
+
+    if(length == NULL) {
+        length = &length16;
+    }
+    if(index >= 0) {
+        s16 = ures_getStringByIndex(resB, index, length, status);
+    } else if(key != NULL) {
+        s16 = ures_getStringByKey(resB, key, length, status);
+    } else {
+        s16 = ures_getString(resB, length, status);
+    }
+    if(U_FAILURE(*status)) {
+        return s16;
+    }
+    length16 = *length;
+
+    /* try the UTF-8 variant of ures_getStringXYZ() */
+    for(forceCopy = FALSE; forceCopy <= TRUE; ++forceCopy) {
+        p8 = buffer8;
+        length8 = (int32_t)sizeof(buffer8);
+        if(index >= 0) {
+            s8 = ures_getUTF8StringByIndex(resB, index, p8, &length8, forceCopy, status);
+        } else if(key != NULL) {
+            s8 = ures_getUTF8StringByKey(resB, key, p8, &length8, forceCopy, status);
+        } else {
+            s8 = ures_getUTF8String(resB, p8, &length8, forceCopy, status);
+        }
+        if(*status == U_INVALID_CHAR_FOUND) {
+            /* the UTF-16 string contains an unpaired surrogate, can't test UTF-8 variant */
+            return s16;
+        }
+        if(*status == U_BUFFER_OVERFLOW_ERROR) {
+            *status = U_ZERO_ERROR;
+            p8 = (char *)malloc(++length8);
+            if(p8 == NULL) {
+                return s16;
+            }
+            if(index >= 0) {
+                s8 = ures_getUTF8StringByIndex(resB, index, p8, &length8, forceCopy, status);
+            } else if(key != NULL) {
+                s8 = ures_getUTF8StringByKey(resB, key, p8, &length8, forceCopy, status);
+            } else {
+                s8 = ures_getUTF8String(resB, p8, &length8, forceCopy, status);
+            }
+        }
+        if(U_FAILURE(*status)) {
+            /* something unexpected happened */
+            if(p8 != buffer8) {
+                free(p8);
+            }
+            return s16;
+        }
+
+        if(forceCopy && s8 != p8) {
+            log_err("ures_getUTF8String(%p, %ld, '%s') did not write the string to dest\n",
+                    resB, (long)index, key);
+        }
+
+        /* verify NUL-termination */
+        if((p8 != buffer8 || length8 < sizeof(buffer8)) && s8[length8] != 0) {
+            log_err("ures_getUTF8String(%p, %ld, '%s') did not NUL-terminate\n",
+                    resB, (long)index, key);
+        }
+        /* verify correct string */
+        i16 = i8 = 0;
+        while(i16 < length16 && i8 < length8) {
+            U16_NEXT(s16, i16, length16, c16);
+            U8_NEXT(s8, i8, length8, c8);
+            if(c16 != c8) {
+                log_err("ures_getUTF8String(%p, %ld, '%s') got a bad string, c16=U+%04lx!=U+%04lx=c8 before i16=%ld\n",
+                        resB, (long)index, key, (long)c16, (long)c8, (long)i16);
+            }
+        }
+        /* verify correct length */
+        if(i16 < length16) {
+            log_err("ures_getUTF8String(%p, %ld, '%s') UTF-8 string too short, length8=%ld, length16=%ld\n",
+                    resB, (long)index, key, (long)length8, (long)length16);
+        }
+        if(i8 < length8) {
+            log_err("ures_getUTF8String(%p, %ld, '%s') UTF-8 string too long, length8=%ld, length16=%ld\n",
+                    resB, (long)index, key, (long)length8, (long)length16);
+        }
+
+        /* clean up */
+        if(p8 != buffer8) {
+            free(p8);
+        }
+    }
+    return s16;
+}
+
+/*
+ * API tests for ures_getUTF8String().
+ * Most cases are handled by tres_getString(), which leaves argument checking
+ * to be tested here.
+ * Since the variants share most of their implementation, we only need to test
+ * one of them.
+ * We also need not test for checking arguments which will be checked by the
+ * UTF-16 ures_getStringXYZ() that are called internally.
+ */
+static void
+TestGetUTF8String() {
+    UResourceBundle *res;
+    const char *testdatapath;
+    char buffer8[16];
+    const char *s8;
+    int32_t length8;
+    UErrorCode status;
+
+    status = U_ZERO_ERROR;
+    testdatapath = loadTestData(&status);
+    if(U_FAILURE(status)) {
+        log_err("Could not load testdata.dat - %s\n", u_errorName(status));
+        return;
+    }
+
+    res = ures_open(testdatapath, "", &status);
+    if(U_FAILURE(status)) {
+        log_err("Unable to ures_open(testdata, \"\") - %s\n", u_errorName(status));
+        return;
+    }
+
+    /* one good call */
+    status = U_ZERO_ERROR;
+    length8 = (int32_t)sizeof(buffer8);
+    s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", buffer8, &length8, FALSE, &status);
+    if(status != U_ZERO_ERROR) {
+        log_err("ures_getUTF8StringByKey(testdata/root string) malfunctioned - %s\n", u_errorName(status));
+    }
+
+    /* negative capacity */
+    status = U_ZERO_ERROR;
+    length8 = -1;
+    s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", buffer8, &length8, FALSE, &status);
+    if(status != U_ILLEGAL_ARGUMENT_ERROR) {
+        log_err("ures_getUTF8StringByKey(capacity<0) malfunctioned - %s\n", u_errorName(status));
+    }
+
+    /* capacity>0 but dest=NULL */
+    status = U_ZERO_ERROR;
+    length8 = (int32_t)sizeof(buffer8);
+    s8 = ures_getUTF8StringByKey(res, "string_only_in_Root", NULL, &length8, FALSE, &status);
+    if(status != U_ILLEGAL_ARGUMENT_ERROR) {
+        log_err("ures_getUTF8StringByKey(dest=NULL capacity>0) malfunctioned - %s\n", u_errorName(status));
+    }
+
+    ures_close(res);
+}