]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/restsnew.cpp
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / restsnew.cpp
index 47669addb1453536fd5b1b26d43b8f230594e4a2..1c19fc8e91deeae7b9a574a7b1a8dfc700efb81d 100644 (file)
@@ -1,11 +1,13 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
- * COPYRIGHT: 
- * Copyright (c) 1997-2005, International Business Machines Corporation and
- * others. All Rights Reserved.
+ * Copyright (c) 1997-2016, International Business Machines
+ * Corporation and others. All Rights Reserved.
  ********************************************************************/
 
 #include "unicode/utypes.h"
 
+#include "cmemory.h"
 #include "cstring.h"
 #include "unicode/unistr.h"
 #include "unicode/resbund.h"
@@ -34,11 +36,11 @@ enum E_Where
 
 //***************************************************************************************
 
-#define CONFIRM_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected) + (UnicodeString)"\n"); }
-#define CONFIRM_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected) + (UnicodeString)"\n"); }
-#define CONFIRM_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected) + (UnicodeString)"\n"); }
+#define CONFIRM_EQ(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected)); }
+#define CONFIRM_GE(actual,expected) if ((actual)>=(expected)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected)); }
+#define CONFIRM_NE(actual,expected) if ((expected)!=(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected)); }
 
-#define CONFIRM_UErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (UnicodeString)u_errorName(actual) + (UnicodeString)" instead of " + (UnicodeString)u_errorName(expected) + (UnicodeString)"\n"); }
+#define CONFIRM_UErrorCode(actual,expected) if ((expected)==(actual)) { record_pass(); } else { record_fail(); errln(action + (UnicodeString)" returned " + (UnicodeString)u_errorName(actual) + (UnicodeString)" instead of " + (UnicodeString)u_errorName(expected)); }
 
 //***************************************************************************************
 
@@ -107,7 +109,7 @@ param[] =
     { "ne",         0,   U_USING_DEFAULT_WARNING,  e_Root,      { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } }
 };
 
-static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
+static int32_t bundles_count = UPRV_LENGTHOF(param);
 
 //***************************************************************************************
 
@@ -171,7 +173,7 @@ NewResourceBundleTest::~NewResourceBundleTest()
 {
     if (param[5].locale) {
         int idx;
-        for (idx = 0; idx < (int)(sizeof(param)/sizeof(param[0])); idx++) {
+        for (idx = 0; idx < UPRV_LENGTHOF(param); idx++) {
             delete param[idx].locale;
             param[idx].locale = NULL;
         }
@@ -182,12 +184,19 @@ void NewResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const cha
 {
     if (exec) logln("TestSuite ResourceBundleTest: ");
     switch (index) {
+#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
     case 0: name = "TestResourceBundles"; if (exec) TestResourceBundles(); break;
     case 1: name = "TestConstruction"; if (exec) TestConstruction(); break;
     case 2: name = "TestIteration"; if (exec) TestIteration(); break;
     case 3: name = "TestOtherAPI";  if(exec) TestOtherAPI(); break;
     case 4: name = "TestNewTypes";  if(exec) TestNewTypes(); break;
+#else
+    case 0: case 1: case 2: case 3: case 4: name = "skip"; break;
+#endif
+
     case 5: name = "TestGetByFallback";  if(exec) TestGetByFallback(); break;
+    case 6: name = "TestFilter";  if(exec) TestFilter(); break;
+
         default: name = ""; break; //needed to end loop
     }
 }
@@ -197,6 +206,20 @@ void NewResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const cha
 void
 NewResourceBundleTest::TestResourceBundles()
 {
+    UErrorCode status = U_ZERO_ERROR;
+    loadTestData(status);
+    if(U_FAILURE(status))
+    {
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
+        return;
+    }
+
+    /* Make sure that users using te_IN for the default locale don't get test failures. */
+    Locale originalDefault;
+    if (Locale::getDefault() == Locale("te_IN")) {
+        Locale::setDefault(Locale("en_US"), status);
+    }
+
     testTag("only_in_Root", TRUE, FALSE, FALSE);
     testTag("only_in_te", FALSE, TRUE, FALSE);
     testTag("only_in_te_IN", FALSE, FALSE, TRUE);
@@ -206,62 +229,78 @@ NewResourceBundleTest::TestResourceBundles()
     testTag("in_te_te_IN", FALSE, TRUE, TRUE);
     testTag("nonexistent", FALSE, FALSE, FALSE);
     logln("Passed: %d\nFailed: %d", pass, fail);
+
+    /* Restore the default locale for the other tests. */
+    Locale::setDefault(originalDefault, status);
 }
 
 void
 NewResourceBundleTest::TestConstruction()
 {
+    UErrorCode   err = U_ZERO_ERROR;
+    Locale       locale("te", "IN");
+
+    const char* testdatapath;
+    testdatapath=loadTestData(err);
+    if(U_FAILURE(err))
     {
-        UErrorCode   err = U_ZERO_ERROR;
-        const char* testdatapath;
-        Locale       locale("te", "IN");
-        testdatapath=loadTestData(err);
-        if(U_FAILURE(err))
-        {
-            errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
-            return;
-        }
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+        return;
+    }
 
-        ResourceBundle  test1((UnicodeString)testdatapath, err);
-        ResourceBundle  test2(testdatapath, locale, err);
-     
-        UnicodeString   result1;
-        UnicodeString   result2;
-
-        result1 = test1.getStringEx("string_in_Root_te_te_IN", err);
-        result2 = test2.getStringEx("string_in_Root_te_te_IN", err);
-        if (U_FAILURE(err)) {
-            errln("Something threw an error in TestConstruction()");
-            return;
-        }
+    /* Make sure that users using te_IN for the default locale don't get test failures. */
+    Locale originalDefault;
+    if (Locale::getDefault() == Locale("te_IN")) {
+        Locale::setDefault(Locale("en_US"), err);
+    }
+
+    ResourceBundle  test1((UnicodeString)testdatapath, err);
+    ResourceBundle  test2(testdatapath, locale, err);
+    
+    UnicodeString   result1;
+    UnicodeString   result2;
+
+    result1 = test1.getStringEx("string_in_Root_te_te_IN", err);
+    result2 = test2.getStringEx("string_in_Root_te_te_IN", err);
+    if (U_FAILURE(err)) {
+        errln("Something threw an error in TestConstruction()");
+        return;
+    }
 
-        logln("for string_in_Root_te_te_IN, root.txt had " + result1);
-        logln("for string_in_Root_te_te_IN, te_IN.txt had " + result2);
+    logln("for string_in_Root_te_te_IN, root.txt had " + result1);
+    logln("for string_in_Root_te_te_IN, te_IN.txt had " + result2);
 
-        if (result1 != "ROOT" || result2 != "TE_IN")
-            errln("Construction test failed; run verbose for more information");
+    if (result1 != "ROOT" || result2 != "TE_IN") {
+        errln("Construction test failed; run verbose for more information");
+    }
 
-        const char* version1;
-        const char* version2;
+    const char* version1;
+    const char* version2;
 
-        version1 = test1.getVersionNumber();
-        version2 = test2.getVersionNumber();
+    version1 = test1.getVersionNumber();
+    version2 = test2.getVersionNumber();
 
-        char *versionID1 = new char[1 + strlen(U_ICU_VERSION) + strlen(version1)]; // + 1 for zero byte
-        char *versionID2 = new char[1 + strlen(U_ICU_VERSION) + strlen(version2)]; // + 1 for zero byte
+    char *versionID1 = new char[1 + strlen(U_ICU_VERSION) + strlen(version1)]; // + 1 for zero byte
+    char *versionID2 = new char[1 + strlen(U_ICU_VERSION) + strlen(version2)]; // + 1 for zero byte
 
-        strcpy(versionID1, "44.0");  // hardcoded, please change if the default.txt file or ResourceBundle::kVersionSeparater is changed.
+    strcpy(versionID1, "44.0");  // hardcoded, please change if the default.txt file or ResourceBundle::kVersionSeparater is changed.
 
-        strcpy(versionID2, "55.0");  // hardcoded, please change if the te_IN.txt file or ResourceBundle::kVersionSeparater is changed.
+    strcpy(versionID2, "55.0");  // hardcoded, please change if the te_IN.txt file or ResourceBundle::kVersionSeparater is changed.
 
-        logln(UnicodeString("getVersionNumber on default.txt returned ") + version1 + UnicodeString(" Expect: " ) + versionID1);
-        logln(UnicodeString("getVersionNumber on te_IN.txt returned ") + version2 + UnicodeString(" Expect: " ) + versionID2);
+    logln(UnicodeString("getVersionNumber on default.txt returned ") + version1 + UnicodeString(" Expect: " ) + versionID1);
+    logln(UnicodeString("getVersionNumber on te_IN.txt returned ") + version2 + UnicodeString(" Expect: " ) + versionID2);
 
-        if (strcmp(version1, versionID1) != 0 || strcmp(version2, versionID2) != 0)
-            errln("getVersionNumber() failed");
-        delete[] versionID1;
-        delete[] versionID2;
+    if (strcmp(version1, versionID1) != 0) {
+        errln("getVersionNumber(version1) failed. %s != %s", version1, versionID1);
+    }
+    if (strcmp(version2, versionID2) != 0) {
+        errln("getVersionNumber(version2) failed. %s != %s", version2, versionID2);
     }
+    delete[] versionID1;
+    delete[] versionID2;
+
+    /* Restore the default locale for the other tests. */
+    Locale::setDefault(originalDefault, err);
 }
 
 void
@@ -280,7 +319,7 @@ NewResourceBundleTest::TestIteration()
     testdatapath=loadTestData(err);
     if(U_FAILURE(err))
     {
-        errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
         return;
     }
 
@@ -296,7 +335,7 @@ NewResourceBundleTest::TestIteration()
     UnicodeString action;
 
 
-    for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
+    for(i=0; i<UPRV_LENGTHOF(data); i=i+2){
         action = "te_IN";
         action +=".get(";
         action += data[i];
@@ -366,13 +405,8 @@ NewResourceBundleTest::TestIteration()
             bundle.getNext(err);
             if(U_FAILURE(err)){
                 errln("ERROR: getNext()  throw an error");
-            }/**/
-
-
+            }
         }
-
-
-
     }
     delete locale;
 }
@@ -399,15 +433,21 @@ equalRB(ResourceBundle &a, ResourceBundle &b) {
 void
 NewResourceBundleTest::TestOtherAPI(){
     UErrorCode   err = U_ZERO_ERROR;
-    const char* testdatapath;
-    testdatapath=loadTestData(err);
+    const char* testdatapath=loadTestData(err);
     UnicodeString tDataPathUS = UnicodeString(testdatapath, "");
 
     if(U_FAILURE(err))
     {
-        errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
         return;
     }
+
+    /* Make sure that users using te_IN for the default locale don't get test failures. */
+    Locale originalDefault;
+    if (Locale::getDefault() == Locale("te_IN")) {
+        Locale::setDefault(Locale("en_US"), err);
+    }
+
     Locale       *locale=new Locale("te_IN");
 
     ResourceBundle test0(tDataPathUS, *locale, err);
@@ -431,12 +471,18 @@ NewResourceBundleTest::TestOtherAPI(){
 
     logln("Testing ResourceBundle(UErrorCode)\n");
     ResourceBundle defaultresource(err);
+    ResourceBundle explicitdefaultresource(NULL, Locale::getDefault(), err);
     if(U_FAILURE(err)){
-        errln("Construction of default resourcebundle failed");
+        errcheckln(err, "Construction of default resourcebundle failed - %s", u_errorName(err));
         return;
     }
-    if(strcmp(defaultresource.getLocale().getName(), Locale::getDefault().getName()) != 0){
-        errln("Construction of default resourcebundle didn't take the defaultlocale\n");
+    // You can't compare the default locale to the resolved locale in the
+    // resource bundle due to aliasing, keywords in the default locale
+    // or the chance that the machine running these tests is using a locale
+    // that isn't available in ICU.
+    if(strcmp(defaultresource.getLocale().getName(), explicitdefaultresource.getLocale().getName()) != 0){
+        errln("Construction of default resourcebundle didn't take the defaultlocale. Expected %s Got %s err=%s\n",
+            explicitdefaultresource.getLocale().getName(), defaultresource.getLocale().getName(), u_errorName(err));
     }
     
 
@@ -444,11 +490,12 @@ NewResourceBundleTest::TestOtherAPI(){
     if(strcmp(copyRes.getName(), defaultresource.getName() ) !=0  ||
         strcmp(test1.getName(), defaultresource.getName() ) ==0 ||
         strcmp(copyRes.getLocale().getName(), defaultresource.getLocale().getName() ) !=0  ||
-        strcmp(test1.getLocale().getName(), defaultresource.getLocale().getName() ) ==0 ){
+        strcmp(test1.getLocale().getName(), defaultresource.getLocale().getName() ) ==0 )
+    {
         errln("copy construction failed\n");
     }
 
-    ResourceBundle defaultSub = defaultresource.get(1, err);
+    ResourceBundle defaultSub = defaultresource.get((int32_t)0, err);
     ResourceBundle defSubCopy(defaultSub);
     if(strcmp(defSubCopy.getName(), defaultSub.getName() ) !=0  ||
         strcmp(defSubCopy.getLocale().getName(), defaultSub.getLocale().getName() ) !=0  ){
@@ -485,99 +532,105 @@ NewResourceBundleTest::TestOtherAPI(){
     };
 
 
-
     testCAPI = ures_open(testdatapath, "te_IN", &err);
 
     if(U_SUCCESS(err)) {
-      // Do the testing
-      // first iteration
-
-      uint32_t i;
-      int32_t count, row=0, col=0;
-      char buf[5];
-      UnicodeString expected;
-      UnicodeString element("TE_IN");
-      UnicodeString action;
-
-
-      for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
-          action = "te_IN";
-          action +=".get(";
-          action += data[i];
-          action +=", err)";
-          err=U_ZERO_ERROR;
-          bundle = ures_getByKey(testCAPI, data[i], bundle, &err); 
-          if(!U_FAILURE(err)){
-            const char* key = NULL;
-              action = "te_IN";
-              action +=".getKey()";
-
-              CONFIRM_EQ((UnicodeString)ures_getKey(bundle), (UnicodeString)data[i]);
-
-              count=0;
-              row=0;
-              while(ures_hasNext(bundle)){
-                  action = data[i];
-                  action +=".getNextString(err)";
-                  row=count;   
-                  UnicodeString got=ures_getNextUnicodeString(bundle, &key, &err);
-                  if(U_SUCCESS(err)){
-                      expected=element;
-                      if(ures_getSize(bundle) > 1){
-                          CONFIRM_EQ(ures_getType(bundle), URES_ARRAY);
-                          expected+=itoa(row, buf);
-                          rowbundle=ures_getByIndex(bundle, row, rowbundle, &err);
-                          if(!U_FAILURE(err) && ures_getSize(rowbundle)>1){
-                              col=0;
-                              while(ures_hasNext(rowbundle)){
-                                  expected=element;
-                                  got=ures_getNextUnicodeString(rowbundle, &key, &err);
-                                  temp = ures_getByIndex(rowbundle, col, temp, &err);
-                                  UnicodeString bla = ures_getUnicodeString(temp, &err);
-                                  UnicodeString bla2 = ures_getUnicodeStringByIndex(rowbundle, col, &err);
-                                  if(!U_FAILURE(err)){
-                                      expected+=itoa(row, buf);
-                                      expected+=itoa(col, buf);
-                                      col++;
-                                      CONFIRM_EQ(got, expected);
-                                      CONFIRM_EQ(bla, expected);
-                                      CONFIRM_EQ(bla2, expected);
-                                  }
-                              }
-                              CONFIRM_EQ(col, ures_getSize(rowbundle));
-                          }
-                      }
-                      else{
-                          CONFIRM_EQ(ures_getType(bundle), (int32_t)URES_STRING);
-                      }
-                  }
-                  CONFIRM_EQ(got, expected);
-                  count++;
-              }
-          }
-      }
-      ures_close(temp);
-      ures_close(rowbundle);
-      ures_close(bundle);
-      ures_close(testCAPI);
-    } else {
-      errln("failed to open a resource bundle\n");
-    }
-
-
+        // Do the testing
+        // first iteration
 
+        uint32_t i;
+        int32_t count, row=0, col=0;
+        char buf[5];
+        UnicodeString expected;
+        UnicodeString element("TE_IN");
+        UnicodeString action;
 
 
+        for(i=0; i<UPRV_LENGTHOF(data); i=i+2){
+            action = "te_IN";
+            action +=".get(";
+            action += data[i];
+            action +=", err)";
+            err=U_ZERO_ERROR;
+            bundle = ures_getByKey(testCAPI, data[i], bundle, &err); 
+            if(!U_FAILURE(err)){
+                const char* key = NULL;
+                action = "te_IN";
+                action +=".getKey()";
+
+                CONFIRM_EQ((UnicodeString)ures_getKey(bundle), (UnicodeString)data[i]);
+
+                count=0;
+                row=0;
+                while(ures_hasNext(bundle)){
+                    action = data[i];
+                    action +=".getNextString(err)";
+                    row=count;   
+                    UnicodeString got=ures_getNextUnicodeString(bundle, &key, &err);
+                    if(U_SUCCESS(err)){
+                        expected=element;
+                        if(ures_getSize(bundle) > 1){
+                            CONFIRM_EQ(ures_getType(bundle), URES_ARRAY);
+                            expected+=itoa(row, buf);
+                            rowbundle=ures_getByIndex(bundle, row, rowbundle, &err);
+                            if(!U_FAILURE(err) && ures_getSize(rowbundle)>1){
+                                col=0;
+                                while(ures_hasNext(rowbundle)){
+                                    expected=element;
+                                    got=ures_getNextUnicodeString(rowbundle, &key, &err);
+                                    temp = ures_getByIndex(rowbundle, col, temp, &err);
+                                    UnicodeString bla = ures_getUnicodeString(temp, &err);
+                                    UnicodeString bla2 = ures_getUnicodeStringByIndex(rowbundle, col, &err);
+                                    if(!U_FAILURE(err)){
+                                        expected+=itoa(row, buf);
+                                        expected+=itoa(col, buf);
+                                        col++;
+                                        CONFIRM_EQ(got, expected);
+                                        CONFIRM_EQ(bla, expected);
+                                        CONFIRM_EQ(bla2, expected);
+                                    }
+                                }
+                                CONFIRM_EQ(col, ures_getSize(rowbundle));
+                            }
+                        }
+                        else{
+                            CONFIRM_EQ(ures_getType(bundle), (int32_t)URES_STRING);
+                        }
+                    }
+                    CONFIRM_EQ(got, expected);
+                    count++;
+                }
+            }
+        }
 
-    
+        // Check that ures_getUnicodeString() & variants return a bogus string if failure.
+        // Same relevant code path whether the failure code is passed in
+        // or comes from a lookup error.
+        UErrorCode failure = U_INTERNAL_PROGRAM_ERROR;
+        assertTrue("ures_getUnicodeString(failure).isBogus()",
+                   ures_getUnicodeString(testCAPI, &failure).isBogus());
+        assertTrue("ures_getNextUnicodeString(failure).isBogus()",
+                   ures_getNextUnicodeString(testCAPI, NULL, &failure).isBogus());
+        assertTrue("ures_getUnicodeStringByIndex(failure).isBogus()",
+                   ures_getUnicodeStringByIndex(testCAPI, 999, &failure).isBogus());
+        assertTrue("ures_getUnicodeStringByKey(failure).isBogus()",
+                   ures_getUnicodeStringByKey(testCAPI, "bogus key", &failure).isBogus());
+
+        ures_close(temp);
+        ures_close(rowbundle);
+        ures_close(bundle);
+        ures_close(testCAPI);
+    } else {
+        errln("failed to open a resource bundle\n");
+    }
 
+    /* Restore the default locale for the other tests. */
+    Locale::setDefault(originalDefault, err);
 }
 
 
 
 
-
-
 //***************************************************************************************
 
 UBool
@@ -607,7 +660,7 @@ NewResourceBundleTest::testTag(const char* frag,
     testdatapath=loadTestData(status);
     if(U_FAILURE(status))
     {
-        errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
         return FALSE;
     }
 
@@ -988,7 +1041,7 @@ NewResourceBundleTest::TestNewTypes() {
 
     if(U_FAILURE(status))
     {
-        logln("Could not load testdata.dat %s \n",u_errorName(status));
+        dataerrln("Could not load testdata.dat %s \n",u_errorName(status));
         return;
     }
 
@@ -996,7 +1049,7 @@ NewResourceBundleTest::TestNewTypes() {
     ResourceBundle bundle(testdatapath, Locale("te_IN"),status);
 
     UnicodeString emptyStr = theBundle.getStringEx("emptystring", status);
-    if(!emptyStr.length()==0) {
+    if(emptyStr.length() != 0) {
       logln("Empty string returned invalid value\n");
     }
 
@@ -1135,7 +1188,7 @@ NewResourceBundleTest::TestGetByFallback() {
 
     heRes.getWithFallback("calendar", status).getWithFallback("islamic-civil", status).getWithFallback("eras", status);
     if(U_FAILURE(status)) {
-        errln("Didn't get Islamic Eras. I know they are there!\n");
+        dataerrln("Didn't get Islamic Eras. I know they are there! - %s", u_errorName(status));
     }
     status = U_ZERO_ERROR;
 
@@ -1147,5 +1200,148 @@ NewResourceBundleTest::TestGetByFallback() {
     status = U_ZERO_ERROR;
 
 }
+
+
+#define REQUIRE_SUCCESS(status) { \
+    if (status.errIfFailureAndReset("line %d", __LINE__)) { \
+        return; \
+    } \
+}
+
+#define REQUIRE_ERROR(expected, status) { \
+    if (!status.expectErrorAndReset(expected, "line %d", __LINE__)) { \
+        return; \
+    } \
+}
+
+/**
+ * Tests the --filterDir option in genrb.
+ *
+ * Input resource text file: test/testdata/filtertest.txt
+ * Input filter rule file: test/testdata/filters/filtertest.txt
+ *
+ * The resource bundle should contain no keys matched by the filter
+ * and should contain all other keys.
+ */
+void NewResourceBundleTest::TestFilter() {
+    IcuTestErrorCode status(*this, "TestFilter");
+
+    ResourceBundle rb(loadTestData(status), "filtertest", status);
+    REQUIRE_SUCCESS(status);
+    assertEquals("rb", rb.getType(), URES_TABLE);
+
+    ResourceBundle alabama = rb.get("alabama", status);
+    REQUIRE_SUCCESS(status);
+    assertEquals("alabama", alabama.getType(), URES_TABLE);
+
+    {
+        ResourceBundle alaska = alabama.get("alaska", status);
+        REQUIRE_SUCCESS(status);
+        assertEquals("alaska", alaska.getType(), URES_TABLE);
+
+        {
+            ResourceBundle arizona = alaska.get("arizona", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("arizona", arizona.getType(), URES_STRING);
+            assertEquals("arizona", u"arkansas", arizona.getString(status));
+            REQUIRE_SUCCESS(status);
+
+            // Filter: california should not be included
+            ResourceBundle california = alaska.get("california", status);
+            REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+        }
+
+        // Filter: connecticut should not be included
+        ResourceBundle connecticut = alabama.get("connecticut", status);
+        REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+    }
+
+    ResourceBundle fornia = rb.get("fornia", status);
+    REQUIRE_SUCCESS(status);
+    assertEquals("fornia", fornia.getType(), URES_TABLE);
+
+    {
+        ResourceBundle hawaii = fornia.get("hawaii", status);
+        REQUIRE_SUCCESS(status);
+        assertEquals("hawaii", hawaii.getType(), URES_STRING);
+        assertEquals("hawaii", u"idaho", hawaii.getString(status));
+        REQUIRE_SUCCESS(status);
+
+        // Filter: illinois should not be included
+        ResourceBundle illinois = fornia.get("illinois", status);
+        REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+    }
+
+    ResourceBundle mississippi = rb.get("mississippi", status);
+    REQUIRE_SUCCESS(status);
+    assertEquals("mississippi", mississippi.getType(), URES_TABLE);
+
+    {
+        ResourceBundle louisiana = mississippi.get("louisiana", status);
+        REQUIRE_SUCCESS(status);
+        assertEquals("louisiana", louisiana.getType(), URES_TABLE);
+
+        {
+            ResourceBundle maine = louisiana.get("maine", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("maine", maine.getType(), URES_STRING);
+            assertEquals("maine", u"maryland", maine.getString(status));
+            REQUIRE_SUCCESS(status);
+
+            ResourceBundle iowa = louisiana.get("iowa", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("iowa", iowa.getType(), URES_STRING);
+            assertEquals("iowa", u"kansas", iowa.getString(status));
+            REQUIRE_SUCCESS(status);
+
+            // Filter: missouri should not be included
+            ResourceBundle missouri = louisiana.get("missouri", status);
+            REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+        }
+
+        ResourceBundle michigan = mississippi.get("michigan", status);
+        REQUIRE_SUCCESS(status);
+        assertEquals("michigan", michigan.getType(), URES_TABLE);
+
+        {
+            ResourceBundle maine = michigan.get("maine", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("maine", maine.getType(), URES_STRING);
+            assertEquals("maine", u"minnesota", maine.getString(status));
+            REQUIRE_SUCCESS(status);
+
+            // Filter: iowa should not be included
+            ResourceBundle iowa = michigan.get("iowa", status);
+            REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+
+            ResourceBundle missouri = michigan.get("missouri", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("missouri", missouri.getType(), URES_STRING);
+            assertEquals("missouri", u"nebraska", missouri.getString(status));
+            REQUIRE_SUCCESS(status);
+        }
+
+        ResourceBundle nevada = mississippi.get("nevada", status);
+        REQUIRE_SUCCESS(status);
+        assertEquals("nevada", nevada.getType(), URES_TABLE);
+
+        {
+            ResourceBundle maine = nevada.get("maine", status);
+            REQUIRE_SUCCESS(status);
+            assertEquals("maine", maine.getType(), URES_STRING);
+            assertEquals("maine", u"new-hampshire", maine.getString(status));
+            REQUIRE_SUCCESS(status);
+
+            // Filter: iowa should not be included
+            ResourceBundle iowa = nevada.get("iowa", status);
+            REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+
+            // Filter: missouri should not be included
+            ResourceBundle missouri = nevada.get("missouri", status);
+            REQUIRE_ERROR(U_MISSING_RESOURCE_ERROR, status);
+        }
+    }
+}
+
 //eof