]> granicus.if.org Git - icu/commitdiff
ICU-10636 make -w tests work without collation rule strings, and without big5han...
authorMarkus Scherer <markus.icu@gmail.com>
Tue, 1 Apr 2014 19:59:27 +0000 (19:59 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Tue, 1 Apr 2014 19:59:27 +0000 (19:59 +0000)
X-SVN-Rev: 35558

icu4c/source/test/cintltst/capitst.c
icu4c/source/test/cintltst/cg7coll.c
icu4c/source/test/cintltst/cmsccoll.c
icu4c/source/test/cintltst/creststn.c
icu4c/source/test/cintltst/nucnvtst.c
icu4c/source/test/intltest/apicoll.cpp
icu4c/source/test/intltest/g7coll.cpp
icu4c/source/test/intltest/intltest.cpp
icu4c/source/tools/ctestfw/ctest.c

index 6a69228d948fab7c13e387956c7ed92953deda54..6457fa161d55d92887e696f835b16c9ced8ddcb8 100644 (file)
@@ -270,6 +270,7 @@ void TestGetDefaultRules(){
 void TestProperty()
 {
     UCollator *col, *ruled;
+    const UChar *rules;
     UChar *disName;
     int32_t len = 0;
     UChar source[12], target[12];
@@ -373,9 +374,20 @@ void TestProperty()
     log_verbose("Default collation getDisplayName ended.\n");
 
     ruled = ucol_open("da_DK", &status);
+    if(U_FAILURE(status)) {
+        log_data_err("ucol_open(\"da_DK\") failed - %s\n", u_errorName(status));
+        ucol_close(col);
+        return;
+    }
     log_verbose("ucol_getRules() testing ...\n");
-    ucol_getRules(ruled, &tempLength);
-    doAssert( tempLength != 0, "getRules() result incorrect" );
+    rules = ucol_getRules(ruled, &tempLength);
+    if(tempLength == 0) {
+        log_data_err("missing da_DK tailoring rule string\n");
+    } else {
+        UChar aa[2] = { 0x61, 0x61 };
+        doAssert(u_strFindFirst(rules, tempLength, aa, 2) != NULL,
+                 "da_DK rules do not contain 'aa'");
+    }
     log_verbose("getRules tests end.\n");
     {
         UChar *buffer = (UChar *)malloc(200000*sizeof(UChar));
@@ -388,8 +400,10 @@ void TestProperty()
 
         log_verbose("ucol_getRulesEx() testing ...\n");
         tempLength=ucol_getRulesEx(col,UCOL_FULL_RULES,buffer,bufLen );
-        doAssert( tempLength != 0, "getRulesEx() result incorrect" );
-        log_verbose("getRules tests end.\n");
+        if(tempLength == 0) {
+            log_data_err("missing *full* rule string\n");
+        }
+        log_verbose("getRulesEx tests end.\n");
         free(buffer);
     }
     ucol_close(ruled);
@@ -964,12 +978,18 @@ void TestOpenVsOpenRules(){
 
         /* grab the rules */
         rules = ucol_getRules(c1, &rulesLength);
+        if (rulesLength == 0) {
+            /* The optional tailoring rule string is either empty (boring) or missing. */
+            ucol_close(c1);
+            continue;
+        }
 
         /* use those rules to create a collator from rules */
         c2 = ucol_openRules(rules, rulesLength, UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH, NULL, &err);
         if (U_FAILURE(err)) {
             log_err("ERROR: Creating collator from rules failed with locale: %s : %s\n", curLoc, myErrorName(err));
-            return;
+            ucol_close(c1);
+            continue;
         }
 
         uld = ulocdata_open(curLoc, &err);
@@ -2366,42 +2386,37 @@ static void TestDefaultKeyword(void) {
     ucol_close(coll);
 }
 
+static UBool uenum_contains(UEnumeration *e, const char *s, UErrorCode *status) {
+    const char *t;
+    uenum_reset(e, status);
+    while(((t = uenum_next(e, NULL, status)) != NULL) && U_SUCCESS(*status)) {
+        if(uprv_strcmp(s, t) == 0) {
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 static void TestGetKeywordValuesForLocale(void) {
-#define INCLUDE_UNIHAN_COLLATION 0
-#define PREFERRED_SIZE 16
 #define MAX_NUMBER_OF_KEYWORDS 9
-    const char *PREFERRED[PREFERRED_SIZE][MAX_NUMBER_OF_KEYWORDS+1] = {
+    const char *PREFERRED[][MAX_NUMBER_OF_KEYWORDS+1] = {
             { "und",            "standard", "eor", "search", NULL, NULL, NULL, NULL, NULL, NULL },
             { "en_US",          "standard", "eor", "search", NULL, NULL, NULL, NULL, NULL, NULL },
             { "en_029",         "standard", "eor", "search", NULL, NULL, NULL, NULL, NULL, NULL },
             { "de_DE",          "standard", "phonebook", "search", "eor", NULL, NULL, NULL, NULL, NULL },
             { "de_Latn_DE",     "standard", "phonebook", "search", "eor", NULL, NULL, NULL, NULL, NULL },
-#if INCLUDE_UNIHAN_COLLATION
-            { "zh",             "pinyin", "big5han", "gb2312han", "stroke", "unihan", "zhuyin", "eor", "search", "standard" },
-            { "zh_Hans",        "pinyin", "big5han", "gb2312han", "stroke", "unihan", "zhuyin", "eor", "search", "standard" },
-            { "zh_CN",          "pinyin", "big5han", "gb2312han", "stroke", "unihan", "zhuyin", "eor", "search", "standard" },
-            { "zh_Hant",        "stroke", "big5han", "gb2312han", "pinyin", "unihan", "zhuyin", "eor", "search", "standard" },
-            { "zh_TW",          "stroke", "big5han", "gb2312han", "pinyin", "unihan", "zhuyin", "eor", "search", "standard" },
-            { "zh__PINYIN",     "pinyin", "big5han", "gb2312han", "stroke", "unihan", "zhuyin", "eor", "search", "standard" },
-#else
-            { "zh",             "pinyin", "big5han", "gb2312han", "stroke", "zhuyin", "eor", "search", "standard", NULL },
-            { "zh_Hans",        "pinyin", "big5han", "gb2312han", "stroke", "zhuyin", "eor", "search", "standard", NULL },
-            { "zh_CN",          "pinyin", "big5han", "gb2312han", "stroke", "zhuyin", "eor", "search", "standard", NULL },
-            { "zh_Hant",        "stroke", "big5han", "gb2312han", "pinyin", "zhuyin", "eor", "search", "standard", NULL },
-            { "zh_TW",          "stroke", "big5han", "gb2312han", "pinyin", "zhuyin", "eor", "search", "standard", NULL },
-            { "zh__PINYIN",     "pinyin", "big5han", "gb2312han", "stroke", "zhuyin", "eor", "search", "standard", NULL },
-#endif
+            { "zh",             "pinyin", "stroke", "eor", "search", "standard", NULL },
+            { "zh_Hans",        "pinyin", "stroke", "eor", "search", "standard", NULL },
+            { "zh_CN",          "pinyin", "stroke", "eor", "search", "standard", NULL },
+            { "zh_Hant",        "stroke", "pinyin", "eor", "search", "standard", NULL },
+            { "zh_TW",          "stroke", "pinyin", "eor", "search", "standard", NULL },
+            { "zh__PINYIN",     "pinyin", "stroke", "eor", "search", "standard", NULL },
             { "es_ES",          "standard", "search", "traditional", "eor", NULL, NULL, NULL, NULL, NULL },
             { "es__TRADITIONAL","traditional", "search", "standard", "eor", NULL, NULL, NULL, NULL, NULL },
             { "und@collation=phonebook",    "standard", "eor", "search", NULL, NULL, NULL, NULL, NULL, NULL },
-            { "de_DE@collation=big5han",    "standard", "phonebook", "search", "eor", NULL, NULL, NULL, NULL, NULL },
+            { "de_DE@collation=pinyin",     "standard", "phonebook", "search", "eor", NULL, NULL, NULL, NULL, NULL },
             { "zzz@collation=xxx",          "standard", "eor", "search", NULL, NULL, NULL, NULL, NULL, NULL }
     };
-#if INCLUDE_UNIHAN_COLLATION
-    const int32_t expectedLength[PREFERRED_SIZE] = { 3, 3, 3, 4, 4, 9, 9, 9, 9, 9, 9, 4, 4, 3, 4, 3 };
-#else
-    const int32_t expectedLength[PREFERRED_SIZE] = { 3, 3, 3, 4, 4, 8, 8, 8, 8, 8, 8, 4, 4, 3, 4, 3 };
-#endif
 
     UErrorCode status = U_ZERO_ERROR;
     UEnumeration *keywordValues = NULL;
@@ -2409,7 +2424,7 @@ static void TestGetKeywordValuesForLocale(void) {
     const char *locale = NULL, *value = NULL;
     UBool errorOccurred = FALSE;
 
-    for (i = 0; i < PREFERRED_SIZE; i++) {
+    for (i = 0; i < LENGTHOF(PREFERRED) && !errorOccurred; i++) {
         locale = PREFERRED[i][0];
         value = NULL;
         valueLength = 0;
@@ -2422,34 +2437,21 @@ static void TestGetKeywordValuesForLocale(void) {
         }
         size = uenum_count(keywordValues, &status);
 
-        if (size == expectedLength[i]) {
-            for (n = 0; n < expectedLength[i]; n++) {
-                if ((value = uenum_next(keywordValues, &valueLength, &status)) != NULL && U_SUCCESS(status)) {
-                    if (uprv_strcmp(value, PREFERRED[i][n+1]) != 0) {
-                        log_err("Keyword values differ: Got [%s] Expected [%s] for locale: %s\n", value, PREFERRED[i][n+1], locale);
-                        errorOccurred = TRUE;
-                        break;
-                    }
-
+        for (n = 0; (value = PREFERRED[i][n+1]) != NULL; n++) {
+            if (!uenum_contains(keywordValues, value, &status)) {
+                if (U_SUCCESS(status)) {
+                    log_err("Keyword value \"%s\" missing for locale: %s\n", value, locale);
                 } else {
                     log_err("While getting keyword value from locale: %s got this error: %s\n", locale, u_errorName(status));
                     errorOccurred = TRUE;
                     break;
                 }
             }
-            if (errorOccurred) {
-                break;
-            }
-        } else {
-            log_err("Number of keywords (%d) does not match expected size (%d) for locale: %s\n", size, expectedLength[i], locale);
-            break;
         }
         uenum_close(keywordValues);
         keywordValues = NULL;
     }
-    if (keywordValues != NULL) {
-        uenum_close(keywordValues);
-    }
+    uenum_close(keywordValues);
 }
 
 static void TestStrcollNull(void) {
index 4eae9735bf6b505efb2ca3e6824589df9638ec65..af0edc5180e5f6d016ef9a80e0777712ef0a1591 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /********************************************************************************
@@ -50,6 +50,7 @@
 #include "callcoll.h"
 #include "unicode/ustring.h"
 
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 const char* locales[8] = {
         "en_US",
@@ -136,36 +137,47 @@ void addRuleBasedCollTest(TestNode** root)
 
 static void TestG7Locales()
 {
-    UCollator *myCollation, *tblColl1;
+    UCollator *myCollation;
     UErrorCode status = U_ZERO_ERROR;
     const UChar *defRules;
     int32_t i, rlen, j, n;
     log_verbose("Testing  ucol_openRules for all the locales\n");
-    for (i = 0; i < 8; i++)
+    for (i = 0; i < LENGTHOF(locales); i++)
     {
+        const char *locale = locales[i];
         status = U_ZERO_ERROR;
-        myCollation = ucol_open(locales[i], &status);
+        myCollation = ucol_open(locale, &status);
         ucol_setAttribute(myCollation, UCOL_STRENGTH, UCOL_QUATERNARY, &status);
         ucol_setAttribute(myCollation, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &status);
 
         if (U_FAILURE(status))
         {
-            log_err_status(status, "Error in creating collator in %s:  %s\n", locales[i], myErrorName(status));
+            log_err_status(status, "Error in creating collator in %s:  %s\n", locale, myErrorName(status));
+            ucol_close(myCollation);
             continue;
         }
 
         defRules = ucol_getRules(myCollation, &rlen);
-        status = U_ZERO_ERROR;
-        tblColl1 = ucol_openRules(defRules, rlen, UCOL_OFF,
-                   UCOL_DEFAULT_STRENGTH,NULL, &status);
-        if (U_FAILURE(status))
-        {
+        if (rlen == 0 && (strcmp(locale, "fr_CA") == 0 || strcmp(locale, "ja_JP") == 0)) {
+            log_data_err("%s UCollator missing rule string\n", locale);
+            if (log_knownIssue("10671", "TestG7Locales does not test ignore-punctuation")) {
+                ucol_close(myCollation);
+                continue;
+            }
+        } else {
+            UCollator *tblColl1;
+            status = U_ZERO_ERROR;
+            tblColl1 = ucol_openRules(defRules, rlen, UCOL_OFF,
+                    UCOL_DEFAULT_STRENGTH,NULL, &status);
             ucol_close(myCollation);
-            log_err_status(status, "Error in creating collator in %s:  %s\n", locales[i], myErrorName(status));
-            continue;
+            if (U_FAILURE(status))
+            {
+                log_err_status(status, "Error in creating collator in %s:  %s\n", locale, myErrorName(status));
+                continue;
+            }
+            myCollation = tblColl1;
         }
 
-        
         log_verbose("Locale  %s\n", locales[i]);
         log_verbose("  tests start...\n");
 
@@ -175,12 +187,11 @@ static void TestG7Locales()
         {
             for (n = j+1; n < FIXEDTESTSET; n++)
             {
-                doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], UCOL_LESS);
+                doTest(myCollation, testCases[results[i][j]], testCases[results[i][n]], UCOL_LESS);
             }
         }
 
         ucol_close(myCollation);
-        ucol_close(tblColl1);
     }
 }
 
index 6e0e2475973c022e86323d44d88999b8db7e5767..687eb1e93eb1fe5fef18b2ec205a6336d4e30344 100644 (file)
@@ -2818,7 +2818,8 @@ static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCo
             errorNo++;
             return errorNo;
         }
-        if(!ucol_equals(source, target)) {
+        /* Note: The tailoring rule string is an optional data item. */
+        if(!ucol_equals(source, target) && sourceRulesLen != 0) {
             log_err("Collator different from collator that was created from the same rules\n");
             errorNo++;
         }
@@ -2830,7 +2831,7 @@ static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCo
 
 static void TestEquals(void) {
     /* ucol_equals is not currently a public API. There is a chance that it will become
-    * something like this, but currently it is only used by RuleBasedCollator::operator==
+    * something like this.
     */
     /* test whether the two collators instantiated from the same locale are equal */
     UErrorCode status = U_ZERO_ERROR;
@@ -5503,6 +5504,11 @@ static void TestImport(void)
     }
 
     virules = (UChar*) ucol_getRules(vicoll, &viruleslength);
+    if(viruleslength == 0) {
+        log_data_err("missing vi tailoring rule string\n");
+        ucol_close(vicoll);
+        return;
+    }
     escoll = ucol_open("es", &status);
     esrules = (UChar*) ucol_getRules(escoll, &esruleslength);
     viesrules = (UChar*)uprv_malloc((viruleslength+esruleslength+1)*sizeof(UChar*));
@@ -5602,6 +5608,11 @@ static void TestImportWithType(void)
         return;
     }
     virules = ucol_getRules(vicoll, &viruleslength);
+    if(viruleslength == 0) {
+        log_data_err("missing vi tailoring rule string\n");
+        ucol_close(vicoll);
+        return;
+    }
     /* decoll = ucol_open("de@collation=phonebook", &status); */
     decoll = ucol_open("de-u-co-phonebk", &status);
     if(U_FAILURE(status)){
index 9e772af0272b94bb2403809b223b447b924053fa..4efa0298f13a8d086eb3b93c57156ec8f84b7bd3 100644 (file)
@@ -1419,7 +1419,18 @@ static void TestGetVersionColl(){
     int32_t locLen;
     const UChar* rules =NULL;
     int32_t len = 0;
-    
+
+    /* test NUL termination of UCARules */
+    resB = ures_open(U_ICUDATA_COLL,locName, &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);
+        status = U_ZERO_ERROR;
+    } else if(u_strlen(rules) != len){
+        log_err("UCARules string not nul terminated! \n");
+    }
+    ures_close(resB);
+
     log_verbose("The ures_getVersion(%s) tests begin : \n", U_ICUDATA_COLL);
     locs = ures_openAvailableLocales(U_ICUDATA_COLL, &status);
     if (U_FAILURE(status)) {
@@ -1427,22 +1438,13 @@ static void TestGetVersionColl(){
        return;
     }
 
-    do{
+    for (;;) {
         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 = tres_getString(resB,-1,"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");
+            break;
         }
         ures_getVersion(resB, versionArray);
         for (i=0; i<4; ++i) {
@@ -1455,10 +1457,14 @@ static void TestGetVersionColl(){
             }
         }
         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));
+        locName = uenum_next(locs, &locLen, &status);
+        if(U_FAILURE(status)) {
+            log_err("uenum_next(locs) error %s\n", u_errorName(status));
+            break;
+        }
+        if(locName == NULL) {
+            break;
+        }
     }
     uenum_close(locs);
 #endif  /* !UCONFIG_NO_COLLATION */
@@ -2633,19 +2639,14 @@ static void TestGetFunctionalEquivalent(void) {
         "f",    "zh_MO",                          "zh@collation=stroke", /* alias of zh_Hant_MO */
         "f",    "zh_Hant_MO",                     "zh@collation=stroke",
         "f",    "zh_TW_STROKE",                   "zh@collation=stroke",
-        "f",    "zh_TW_STROKE@collation=big5han", "zh@collation=big5han",
+        "f",    "zh_TW_STROKE@collation=pinyin",  "zh",
         "f",    "sv_CN@calendar=japanese",        "sv",
         "t",    "sv@calendar=japanese",           "sv",
-        "f",    "zh_TW@collation=big5han",        "zh@collation=big5han", /* alias of zh_Hant_TW */
-        "f",    "zh_Hant_TW@collation=big5han",   "zh@collation=big5han",
-        "f",    "zh_TW@collation=gb2312han",      "zh@collation=gb2312han", /* alias of zh_Hant_TW */
-        "f",    "zh_Hant_TW@collation=gb2312han", "zh@collation=gb2312han",
-        "f",    "zh_CN@collation=big5han",        "zh@collation=big5han", /* alias of zh_Hans_CN */
-        "f",    "zh_Hans_CN@collation=big5han",   "zh@collation=big5han",
-        "f",    "zh_CN@collation=gb2312han",      "zh@collation=gb2312han", /* alias of zh_Hans_CN */
-        "f",    "zh_Hans_CN@collation=gb2312han", "zh@collation=gb2312han",
-        "t",    "zh@collation=big5han",           "zh@collation=big5han",
-        "t",    "zh@collation=gb2312han",         "zh@collation=gb2312han",
+        "f",    "zh_TW@collation=pinyin",         "zh", /* alias of zh_Hant_TW */
+        "f",    "zh_Hant_TW@collation=pinyin",    "zh",
+        "f",    "zh_CN@collation=stroke",         "zh@collation=stroke", /* alias of zh_Hans_CN */
+        "f",    "zh_Hans_CN@collation=stroke",    "zh@collation=stroke",
+        "t",    "de@collation=phonebook",         "de@collation=phonebook",
         "t",    "hi@collation=standard",          "hi",
         "f",    "hi_AU@collation=standard;currency=CHF;calendar=buddhist",    "hi",
         "f",    "sv_SE@collation=pinyin",         "sv", /* bug 4582 tests */
index f4a443cd9627b3d6c022da5ddb98fcf6c27ae6e1..08b98ffe03b3b8954ecec8df32f3d6112558c866 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1997-2012, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 /*******************************************************************************
@@ -5397,6 +5397,12 @@ static void TestJitterbug981(){
     }
 
     rules = ucol_getRules(myCollator, &rules_length);
+    if(rules_length == 0) {
+        log_data_err("missing zh tailoring rule string\n");
+        ucol_close(myCollator);
+        ucnv_close(utf8cnv);
+        return;
+    }
     buff_size = rules_length * ucnv_getMaxCharSize(utf8cnv);
     buff = malloc(buff_size);
 
index 716fbd98be982a514a92a4237f5fc28aa0fd1e51..4b3dc850acc9415ee15ecfd35140c9c3a589ceff 100644 (file)
@@ -164,7 +164,16 @@ CollationAPITest::TestProperty(/* char* par */)
     delete col; col = 0;
     RuleBasedCollator *rcol = (RuleBasedCollator *)Collator::createInstance("da_DK",
                                                                             success);
-    doAssert(rcol->getRules().length() != 0, "da_DK rules does not have length 0");
+    if (U_FAILURE(success)) {
+        errcheckln(success, "Collator::createInstance(\"da_DK\") failed - %s", u_errorName(success));
+        return;
+    }
+    const UnicodeString &daRules = rcol->getRules();
+    if(daRules.isEmpty()) {
+        dataerrln("missing da_DK tailoring rule string");
+    } else {
+        doAssert(daRules.indexOf("aa") >= 0, "da_DK rules do not contain 'aa'");
+    }
     delete rcol;
 
     col = Collator::createInstance(Locale::getFrench(), success);
index e49a6443759f92251f488e62c48c5a38ab0db9cb..da5ed66cc98f2322a922e5590e287da41e6e6f8d 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -15,6 +15,7 @@
 #include "g7coll.h"
 #include "sfwdchit.h"
 
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 static const UChar testCases[][G7CollationTest::MAX_TOKEN_LEN] = {
     {  0x0062 /*'b'*/, 0x006c /*'l'*/, 0x0061 /*'a'*/, 0x0062 /*'c'*/, 0x006b /*'k'*/, 
@@ -91,47 +92,39 @@ void G7CollationTest::TestG7Locales(/* char* par */)
         Locale("ja", "JP", "")
     };
 
-
-    for (i = 0; i < 8; i++)
+    for (i = 0; i < LENGTHOF(locales); i++)
     {
-        Collator *myCollation= 0;
         UnicodeString dispName;
         UErrorCode status = U_ZERO_ERROR;
-        RuleBasedCollator* tblColl1 = 0;
 
-        myCollation = Collator::createInstance(locales[i], status);
+        const Locale &locale = locales[i];
+        LocalPointer<Collator> myCollation(Collator::createInstance(locale, status));
         if(U_FAILURE(status)) {
-          delete myCollation;
           errcheckln(status, "Couldn't instantiate collator. Error: %s", u_errorName(status));
           return;
         }
         myCollation->setStrength(Collator::QUATERNARY);
         myCollation->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, status);
-        if (U_FAILURE(status))
-        {
-            UnicodeString msg;
-
-            msg += "Locale ";
-            msg += locales[i].getDisplayName(dispName);
-            msg += "creation failed.";
-
-            errln(msg);
+        if (U_FAILURE(status)) {
+            errln("Locale %s creation failed - %s", locale.getName(), u_errorName(status));
             continue;
         }
 
-//        const UnicodeString& defRules = ((RuleBasedCollator*)myCollation)->getRules();
-        status = U_ZERO_ERROR;
-        tblColl1 = new RuleBasedCollator(((RuleBasedCollator*)myCollation)->getRules(), status);
-        if (U_FAILURE(status))
-        {
-            UnicodeString msg, name;
-
-            msg += "Recreate ";
-            msg += locales[i].getDisplayName(name);
-            msg += "collation failed.";
-
-            errln(msg);
-            continue;
+        const UnicodeString &rules = ((RuleBasedCollator*)myCollation.getAlias())->getRules();
+        if (rules.isEmpty() &&
+                (locale == Locale::getCanadaFrench() || locale == Locale::getJapanese())) {
+            dataerrln("%s Collator missing rule string", locale.getName());
+            if (logKnownIssue("10671", "TestG7Locales does not test ignore-punctuation")) {
+                continue;
+            }
+        } else {
+            status = U_ZERO_ERROR;
+            RuleBasedCollator *tblColl1 = new RuleBasedCollator(rules, status);
+            if (U_FAILURE(status)) {
+                errln("Recreate %s collation failed - %s", locale.getName(), u_errorName(status));
+                continue;
+            }
+            myCollation.adoptInstead(tblColl1);
         }
 
         UnicodeString msg;
@@ -146,12 +139,9 @@ void G7CollationTest::TestG7Locales(/* char* par */)
         {
             for (n = j+1; n < FIXEDTESTSET; n++)
             {
-                doTest(tblColl1, testCases[results[i][j]], testCases[results[i][n]], Collator::LESS);
+                doTest(myCollation.getAlias(), testCases[results[i][j]], testCases[results[i][n]], Collator::LESS);
             }
         }
-
-        delete myCollation;
-        delete tblColl1;
     }
 }
 
index 8c4371510dbeef4da36c7ab333fff67d8327a0aa..538a6f43023b27cacd6c2b8bae5b17b74fd02e92 100644 (file)
@@ -977,10 +977,12 @@ UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) {
   UBool firstForTicket, firstForWhere;
   knownList = udbg_knownIssue_openU(knownList, ticket, fullpath, msg2.getTerminatedBuffer(), &firstForTicket, &firstForWhere);
 
+  msg2 = UNICODE_STRING_SIMPLE("(Known issue #") +
+      UnicodeString(ticket, -1, US_INV) + UNICODE_STRING_SIMPLE(") ") + msg;
   if(firstForTicket || firstForWhere) {
-    infoln(UnicodeString("(Known issue #","") + UnicodeString(ticket,"")+ UnicodeString(") \"","") + msg);
+    infoln(msg2);
   } else {
-    logln(UnicodeString("(Known issue #","") + UnicodeString(ticket,"")+ UnicodeString(") \"","") + msg);
+    logln(msg2);
   }
 
   return TRUE;
index a09bb19efba109fb9306314179ae083cabd28d1a..da641f2d7568f05cb0b3b7ba466cc5a25746e3cf 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ********************************************************************************
 *
-*   Copyright (C) 1996-2013, International Business Machines
+*   Copyright (C) 1996-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ********************************************************************************
@@ -523,6 +523,7 @@ runTests ( const TestNode *root )
         fprintf(stdout, "(To run suppressed tests, use the -K option.) \n\n");
       }
       udbg_knownIssue_close(knownList);
+      knownList = NULL;
     }
 
     if (ERROR_COUNT)
@@ -706,9 +707,9 @@ static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap
                                      &firstForTicket, &firstForWhere);
 
     if(firstForTicket || firstForWhere) {
-      log_info("(Known issue #%s) %s", ticket, buf);
+      log_info("(Known issue #%s) %s\n", ticket, buf);
     } else {
-      log_verbose("(Known issue #%s) %s", ticket, buf);
+      log_verbose("(Known issue #%s) %s\n", ticket, buf);
     }
 
     return TRUE;