+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2000-2006, International Business Machines Corporation and
+ * Copyright (c) 2000-2016, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
*
* Date Name Description
* 08/05/2000 Yves Creation
-*******************************************************************************
+******************************************************************************
*/
#include "unicode/ucnv.h"
#include "unicode/ustring.h"
+#include "cmemory.h"
#include "cstring.h"
#include "cintltst.h"
-#define ARRAY_SIZE(array) (int32_t)(sizeof array / sizeof array[0])
-
static void TestStandardName(void);
static void TestStandardNames(void);
static void TestCanonicalName(void);
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);
res = 0;
}
else if (!tag && expected) {
- log_err("FAIL: could not find %s canonical name for %s\n", (standard ? "\"\"" : standard), name);
+ 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) != 0)) {
const char *enumName, *testName;
int32_t enumCount = uenum_count(myEnum, &err);
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) {
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;
UChar testName[256];
int32_t len;
const UChar *enumName = uenum_unext(myEnum, &len, &err);
- u_uastrncpy(testName, expected[idx], sizeof(testName)/sizeof(testName[0]));
+ u_uastrncpy(testName, expected[idx], UPRV_LENGTHOF(testName));
if (u_strcmp(enumName, testName) != 0 || U_FAILURE(err)
|| len != (int32_t)uprv_strlen(expected[idx]))
{
"csASCII",
"iso-ir-6",
"cp367",
+ "IBM367",
};
static const char *asciiMIME[] = {
"US-ASCII"
"ISO-2022-KR",
};
- doTestNames("ASCII", "IANA", asciiIANA, ARRAY_SIZE(asciiIANA));
- doTestNames("US-ASCII", "IANA", asciiIANA, ARRAY_SIZE(asciiIANA));
- doTestNames("ASCII", "MIME", asciiMIME, ARRAY_SIZE(asciiMIME));
- doTestNames("ascii", "mime", asciiMIME, ARRAY_SIZE(asciiMIME));
+ doTestNames("ASCII", "IANA", asciiIANA, UPRV_LENGTHOF(asciiIANA));
+ doTestNames("US-ASCII", "IANA", asciiIANA, UPRV_LENGTHOF(asciiIANA));
+ doTestNames("ASCII", "MIME", asciiMIME, UPRV_LENGTHOF(asciiMIME));
+ doTestNames("ascii", "mime", asciiMIME, UPRV_LENGTHOF(asciiMIME));
doTestNames("ASCII", "crazy", asciiMIME, -1);
doTestNames("crazy", "MIME", asciiMIME, -1);
doTestNames("LMBCS-1", "MIME", asciiMIME, 0);
- doTestNames("ISO_2022,locale=ko,version=0", "MIME", iso2022MIME, ARRAY_SIZE(iso2022MIME));
- doTestNames("csiso2022kr", "MIME", iso2022MIME, ARRAY_SIZE(iso2022MIME));
+ doTestNames("ISO_2022,locale=ko,version=0", "MIME", iso2022MIME, UPRV_LENGTHOF(iso2022MIME));
+ doTestNames("csiso2022kr", "MIME", iso2022MIME, UPRV_LENGTHOF(iso2022MIME));
log_verbose(" Testing unext()\n");
- doTestUCharNames("ASCII", "IANA", asciiIANA, ARRAY_SIZE(asciiIANA));
+ doTestUCharNames("ASCII", "IANA", asciiIANA, UPRV_LENGTHOF(asciiIANA));
}