X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..ba6d6ed23dec08b1cd5700a128c0752491c10ac9:/icuSources/test/cintltst/stdnmtst.c diff --git a/icuSources/test/cintltst/stdnmtst.c b/icuSources/test/cintltst/stdnmtst.c index b4e6445f..f8d73195 100644 --- a/icuSources/test/cintltst/stdnmtst.c +++ b/icuSources/test/cintltst/stdnmtst.c @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 2000-2003, International Business Machines Corporation and + * Copyright (c) 2000-2009, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /* @@ -10,7 +10,7 @@ * * Date Name Description * 08/05/2000 Yves Creation -******************************************************************************* +****************************************************************************** */ #include "unicode/ucnv.h" @@ -44,7 +44,7 @@ static int dotestname(const char *name, const char *standard, const char *expect error = U_ZERO_ERROR; tag = ucnv_getStandardName(name, standard, &error); if (!tag && expected) { - log_err("FAIL: could not find %s standard name for %s\n", standard, name); + log_err_status(error, "FAIL: could not find %s standard name for %s\n", standard, name); res = 0; } else if (expected && (name == tag || uprv_strcmp(expected, tag))) { log_err("FAIL: expected %s for %s standard name for %s, got %s\n", expected, standard, name, tag); @@ -100,7 +100,7 @@ static void TestStandardName() /*dotestname("cp1252", "MIME", "windows-1252") &&*/ dotestname("ascii", "MIME", "US-ASCII") && dotestname("csiso2022jp2", "MIME", "ISO-2022-JP-2") && - dotestname("Iso20-22__cN", "MIME", "ISO-2022-CN") && + dotestname("Iso20-22__cN", "IANA", "ISO-2022-CN") && dotestname("ascii", "IANA", "ANSI_X3.4-1968") && dotestname("cp850", "IANA", "IBM850") && dotestname("crazy", "MIME", NULL) && @@ -122,13 +122,18 @@ static int dotestconv(const char *name, const char *standard, const char *expect if (tag && !expected) { log_err("FAIL: Unexpectedly found %s canonical name for %s, got %s\n", standard, name, tag); res = 0; - } else if (!tag && expected) { - log_err("FAIL: could not find %s canonical name for %s\n", (standard ? "\"\"" : standard), name); + } + else if (!tag && expected) { + log_err_status(error, "FAIL: could not find %s canonical name for %s\n", (standard ? "\"\"" : standard), name); res = 0; - } else if (expected && (name == tag || uprv_strcmp(expected, tag)) && error == U_ZERO_ERROR) { + } + else if (expected && (name == tag || uprv_strcmp(expected, tag) != 0)) { log_err("FAIL: expected %s for %s canonical name for %s, got %s\n", expected, standard, name, tag); res = 0; } + else { + log_verbose("PASS: (\"%s\", \"%s\") -> %s == %s \n", name, standard, tag, expected); + } return res; } @@ -147,10 +152,10 @@ static void TestCanonicalName() dotestconv("ibm-5305", "IANA", NULL) && /* mapping does not exist */ dotestconv("cp1208", "", "UTF-8") && /* default name due to ordering */ dotestconv("UTF16_BigEndian", "", "UTF-16BE") && /* non-default name due to ordering */ - dotestconv("ISO-2022-CN", "MIME", "ISO_2022,locale=zh,version=0") &&/* default name */ - dotestconv("Shift_JIS", "MIME", "ibm-943_P14A-1999") &&/* ambiguous alias */ + dotestconv("ISO-2022-CN", "IANA", "ISO_2022,locale=zh,version=0") &&/* default name */ + dotestconv("Shift_JIS", "MIME", "ibm-943_P15A-2003") &&/* ambiguous alias */ dotestconv("Shift_JIS", "", "ibm-943_P130-1999") &&/* ambiguous alias */ - dotestconv("ibm-943", "", "ibm-943_P14A-1999") &&/* ambiguous alias */ + dotestconv("ibm-943", "", "ibm-943_P15A-2003") &&/* ambiguous alias */ dotestconv("ibm-943", "IBM", "ibm-943_P130-1999") &&/* ambiguous alias */ dotestconv("ibm-1363", "", "ibm-1363_P11B-1998") &&/* ambiguous alias */ dotestconv("ibm-1363", "IBM", "ibm-1363_P110-1997") &&/* ambiguous alias */ @@ -165,10 +170,16 @@ static void TestCanonicalName() static UBool doTestNames(const char *name, const char *standard, const char **expected, int32_t size) { UErrorCode err = U_ZERO_ERROR; UEnumeration *myEnum = ucnv_openStandardNames(name, standard, &err); + const char *enumName, *testName; int32_t enumCount = uenum_count(myEnum, &err); - int32_t idx, repeatTimes = 3; + int32_t idx, len, repeatTimes = 3; + + if (err == U_FILE_ACCESS_ERROR) { + log_data_err("Unable to open standard names for %s of standard: %s\n", name, standard); + return 0; + } if (size != enumCount) { - log_err("FAIL: different size arrays. Got %d. Expected %d\n", enumCount, size); + log_err("FAIL: different size arrays for %s. Got %d. Expected %d\n", name, enumCount, size); return 0; } if (size < 0 && myEnum) { @@ -178,9 +189,8 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex log_verbose("\n%s %s\n", name, standard); while (repeatTimes-- > 0) { for (idx = 0; idx < enumCount; idx++) { - int32_t len; - const char *enumName = uenum_next(myEnum, &len, &err); - const char *testName = expected[idx]; + enumName = uenum_next(myEnum, &len, &err); + testName = expected[idx]; if (uprv_strcmp(enumName, testName) != 0 || U_FAILURE(err) || len != (int32_t)uprv_strlen(expected[idx])) { @@ -190,6 +200,13 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex log_verbose("%s\n", enumName); err = U_ZERO_ERROR; } + if (enumCount >= 0) { + /* one past the list of all names must return NULL */ + enumName = uenum_next(myEnum, &len, &err); + if (enumName != NULL || len != 0 || U_FAILURE(err)) { + log_err("FAIL: uenum_next(past the list) did not return NULL[0] with U_SUCCESS(). name=%s standard=%s len=%d err=%s\n", name, standard, len, u_errorName(err)); + } + } log_verbose("\n reset\n"); uenum_reset(myEnum, &err); if (U_FAILURE(err)) { @@ -207,6 +224,12 @@ static UBool doTestUCharNames(const char *name, const char *standard, const char UEnumeration *myEnum = ucnv_openStandardNames(name, standard, &err); int32_t enumCount = uenum_count(myEnum, &err); int32_t idx, repeatTimes = 3; + + if (err == U_FILE_ACCESS_ERROR) { + log_data_err("Unable to open standard names for %s of standard: %s\n", name, standard); + return 0; + } + if (size != enumCount) { log_err("FAIL: different size arrays. Got %d. Expected %d\n", enumCount, size); return 0; @@ -256,6 +279,7 @@ static void TestStandardNames() "csASCII", "iso-ir-6", "cp367", + "IBM367", }; static const char *asciiMIME[] = { "US-ASCII"