]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/restest.cpp
ICU-57163.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / restest.cpp
index 0f9175b02245badeed892eab162c893fe952d897..30689b06f62893c82cf9a7d6b4b5bbecced259b7 100644 (file)
@@ -1,11 +1,12 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2008, International Business Machines Corporation and
+ * 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/uniset.h"
@@ -21,7 +22,6 @@
 
 static const UChar kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
 static const int32_t kErrorLength = 5;
-static const int32_t kERROR_COUNT = -1234567;
 
 //***************************************************************************************
 
@@ -108,7 +108,7 @@ param[] =
     { "ne",         NULL,   U_USING_DEFAULT_WARNING,  e_Root,      { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } }
 };
 
-static const int32_t bundles_count = sizeof(param) / sizeof(param[0]);
+static const int32_t bundles_count = UPRV_LENGTHOF(param);
 
 //***************************************************************************************
 
@@ -172,7 +172,7 @@ ResourceBundleTest::~ResourceBundleTest()
 {
     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;
         }
@@ -183,11 +183,16 @@ void ResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const char*
 {
     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 = "TestExemplar"; if (exec) TestExemplar(); break;
-    case 3: name = "TestGetSize"; if (exec) TestGetSize(); break;
-    case 4: name = "TestGetLocaleByType"; if (exec) TestGetLocaleByType(); break;
+    case 2: name = "TestGetSize"; if (exec) TestGetSize(); break;
+    case 3: name = "TestGetLocaleByType"; if (exec) TestGetLocaleByType(); break;
+#else
+    case 0: case 1: case 2: case 3: name = "skip"; break;
+#endif
+
+    case 4: name = "TestExemplar"; if (exec) TestExemplar(); break;
         default: name = ""; break; //needed to end loop
     }
 }
@@ -202,7 +207,7 @@ ResourceBundleTest::TestResourceBundles()
     loadTestData(status);
     if(U_FAILURE(status))
     {
-        dataerrln("[DATA] Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
         return;
     }
 
@@ -235,7 +240,7 @@ ResourceBundleTest::TestConstruction()
     const char* testdatapath=loadTestData(err);
     if(U_FAILURE(err))
     {
-        dataerrln("[DATA] Could not load testdata.dat " + UnicodeString(testdatapath) +  ", " + UnicodeString(u_errorName(err)));
+        dataerrln("Could not load testdata.dat " + UnicodeString(testdatapath) +  ", " + UnicodeString(u_errorName(err)));
         return;
     }
 
@@ -319,7 +324,7 @@ ResourceBundleTest::testTag(const char* frag,
     testdatapath=loadTestData(status);
     if(U_FAILURE(status))
     {
-        dataerrln("[DATA] Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
+        dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
         return FALSE;
     }
 
@@ -534,7 +539,7 @@ ResourceBundleTest::TestGetSize(void)
     
     if(U_FAILURE(status))
     {
-        dataerrln("[DATA] Could not load testdata.dat %s\n", u_errorName(status));
+        dataerrln("Could not load testdata.dat %s\n", u_errorName(status));
         return;
     }
     
@@ -545,7 +550,7 @@ ResourceBundleTest::TestGetSize(void)
         return;
     }
     
-    for(i = 0; i < (int32_t)(sizeof(test)/sizeof(test[0])); i++) {
+    for(i = 0; i < UPRV_LENGTHOF(test); i++) {
         ResourceBundle res = rb.get(test[i].key, status);
         if(U_FAILURE(status))
         {
@@ -588,11 +593,11 @@ ResourceBundleTest::TestGetLocaleByType(void)
     
     if(U_FAILURE(status))
     {
-        dataerrln("[DATA] Could not load testdata.dat %s\n", u_errorName(status));
+        dataerrln("Could not load testdata.dat %s\n", u_errorName(status));
         return;
     }
     
-    for(i = 0; i < (int32_t)(sizeof(test)/sizeof(test[0])); i++) {
+    for(i = 0; i < UPRV_LENGTHOF(test); i++) {
         ResourceBundle rb(testdatapath, test[i].requestedLocale, status);
         if(U_FAILURE(status))
         {
@@ -608,11 +613,12 @@ ResourceBundleTest::TestGetLocaleByType(void)
             status = U_ZERO_ERROR;
             continue;
         }
-        
+
         locale = res.getLocale(ULOC_REQUESTED_LOCALE, status);
-        if(locale != Locale::getDefault()) {
+        if(U_SUCCESS(status) && locale != Locale::getDefault()) {
             err("Expected requested locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
         }
+        status = U_ZERO_ERROR;
         locale = res.getLocale(ULOC_VALID_LOCALE, status);
         if(strcmp(locale.getName(), test[i].validLocale) != 0) {
             err("Expected valid locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
@@ -623,6 +629,3 @@ ResourceBundleTest::TestGetLocaleByType(void)
         }
     }
 }
-
-//eof
-