/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2008, International Business Machines Corporation and
+ * Copyright (c) 1997-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
#define RESTEST_HEAP_CHECK 0
#include "unicode/uloc.h"
+#include "unicode/ulocdata.h"
#include "uresimp.h"
#include "creststn.h"
#include "unicode/ctest.h"
#include "ucbuf.h"
+#include "ureslocs.h"
+
static int32_t pass;
static int32_t fail;
static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
+
/*static void printUChars(UChar*);*/
static void TestDecodedBundle(void);
static void TestGetKeywordValues(void);
static void TestCLDRStyleAliases(void);
static void TestFallbackCodes(void);
static void TestGetUTF8String(void);
+static void TestCLDRVersion(void);
/***************************************************************************************/
void addNEWResourceBundleTest(TestNode** root)
{
addTest(root, &TestErrorCodes, "tsutil/creststn/TestErrorCodes");
+#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
addTest(root, &TestEmptyBundle, "tsutil/creststn/TestEmptyBundle");
addTest(root, &TestConstruction1, "tsutil/creststn/TestConstruction1");
addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundles");
- addTest(root, &TestFallback, "tsutil/creststn/TestFallback");
- addTest(root, &TestGetVersion, "tsutil/creststn/TestGetVersion");
- addTest(root, &TestGetVersionColl, "tsutil/creststn/TestGetVersionColl");
- addTest(root, &TestAliasConflict, "tsutil/creststn/TestAliasConflict");
addTest(root, &TestNewTypes, "tsutil/creststn/TestNewTypes");
addTest(root, &TestEmptyTypes, "tsutil/creststn/TestEmptyTypes");
addTest(root, &TestBinaryCollationData, "tsutil/creststn/TestBinaryCollationData");
addTest(root, &TestDecodedBundle, "tsutil/creststn/TestDecodedBundle");
addTest(root, &TestResourceLevelAliasing, "tsutil/creststn/TestResourceLevelAliasing");
addTest(root, &TestDirectAccess, "tsutil/creststn/TestDirectAccess");
+ addTest(root, &TestXPath, "tsutil/creststn/TestXPath");
+ addTest(root, &TestCLDRStyleAliases, "tsutil/creststn/TestCLDRStyleAliases");
+ addTest(root, &TestFallbackCodes, "tsutil/creststn/TestFallbackCodes");
+ addTest(root, &TestGetUTF8String, "tsutil/creststn/TestGetUTF8String");
+ addTest(root, &TestCLDRVersion, "tsutil/creststn/TestCLDRVersion");
+#endif
+ addTest(root, &TestFallback, "tsutil/creststn/TestFallback");
+ addTest(root, &TestGetVersion, "tsutil/creststn/TestGetVersion");
+ addTest(root, &TestGetVersionColl, "tsutil/creststn/TestGetVersionColl");
+ addTest(root, &TestAliasConflict, "tsutil/creststn/TestAliasConflict");
addTest(root, &TestGetKeywordValues, "tsutil/creststn/TestGetKeywordValues");
addTest(root, &TestGetFunctionalEquivalent,"tsutil/creststn/TestGetFunctionalEquivalent");
addTest(root, &TestJB3763, "tsutil/creststn/TestJB3763");
- addTest(root, &TestXPath, "tsutil/creststn/TestXPath");
- addTest(root, &TestCLDRStyleAliases, "tsutil/creststn/TestCLDRStyleAliases");
- addTest(root, &TestFallbackCodes, "tsutil/creststn/TestFallbackCodes");
addTest(root, &TestStackReuse, "tsutil/creststn/TestStackReuse");
- addTest(root, &TestGetUTF8String, "tsutil/creststn/TestGetUTF8String");
}
log_data_err("Resource not present, cannot test (%s:%d)\n", __FILE__, line);
}
if(status != expected) {
- log_err("%s:%d: Expected error code %s, got error code %s\n", __FILE__, line, u_errorName(expected), u_errorName(status));
+ log_err_status(status, "%s:%d: Expected error code %s, got error code %s\n", __FILE__, line, u_errorName(expected), u_errorName(status));
}
}
checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
ures_close(r);
- /* this bundle should return zero error, so it shouldn't change the status*/
+ /* this bundle should return zero error, so it shouldn't change the status */
status = U_USING_DEFAULT_WARNING;
r = ures_open(NULL, "ti_ER", &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
/* we look up the resource which is aliased, but it lives in fallback */
+
if(U_SUCCESS(status) && r != NULL) {
- status = U_USING_DEFAULT_WARNING;
- r2 = ures_getByKey(r, "Languages", NULL, &status); /* languages of 'ti' aliases to 'am' */
+ status = U_USING_DEFAULT_WARNING;
+ r2 = ures_getByKey(r, "LocaleScript", NULL, &status); /* LocaleScript lives in ti */
checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
- }
+ }
ures_close(r);
- /* this bundle should return zero error, so it shouldn't change the status*/
+ /* this bundle should return zero error, so it shouldn't change the status */
status = U_USING_DEFAULT_WARNING;
- r = ures_open(NULL, "ti", &status);
+ r = ures_open(U_ICUDATA_REGION, "ti", &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
/* we look up the resource which is aliased and at our level */
- if(U_SUCCESS(status) && r != NULL) {
- status = U_USING_DEFAULT_WARNING;
- r2 = ures_getByKey(r, "Languages", r2, &status);
+ /* TODO: restore the following test when cldrbug 3058: is fixed */
+ if(U_SUCCESS(status) && r != NULL && isICUVersionAtLeast(50, 0, 0)) {
+ status = U_USING_DEFAULT_WARNING;
+ r2 = ures_getByKey(r, "Countries", r2, &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
}
ures_close(r);
ures_close(r2);
/** Now, with the collation bundle **/
-
+
/* first bundle should return fallback warning */
r = ures_open(U_ICUDATA_COLL, "sr_YU_VOJVODINA", &status);
checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
ures_close(r);
- /* this bundle should return zero error, so it shouldn't change the status*/
+ /* this bundle should return zero error, so it shouldn't change the status */
status = U_USING_FALLBACK_WARNING;
r = ures_open(U_ICUDATA_COLL, "sr", &status);
checkStatus(__LINE__, U_USING_FALLBACK_WARNING, status);
/* we look up the resource which is aliased */
if(U_SUCCESS(status) && r != NULL) {
- status = U_USING_DEFAULT_WARNING;
+ status = U_USING_DEFAULT_WARNING;
r2 = ures_getByKey(r, "collations", NULL, &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
- }
+ }
ures_close(r);
- /* this bundle should return zero error, so it shouldn't change the status*/
+ /* this bundle should return zero error, so it shouldn't change the status */
status = U_USING_DEFAULT_WARNING;
r = ures_open(U_ICUDATA_COLL, "sr", &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
/* we look up the resource which is aliased and at our level */
if(U_SUCCESS(status) && r != NULL) {
- status = U_USING_DEFAULT_WARNING;
+ status = U_USING_DEFAULT_WARNING;
r2 = ures_getByKey(r, "collations", r2, &status);
checkStatus(__LINE__, U_USING_DEFAULT_WARNING, status);
}
he = ures_open(NULL, "he", &status);
iw = ures_open(NULL, "iw", &status);
if(U_FAILURE(status)) {
- log_err("Failed to get resource with %s\n", myErrorName(status));
+ log_err_status(status, "Failed to get resource with %s\n", myErrorName(status));
}
ures_close(iw);
result = ures_getStringByKey(he, "ExemplarCharacters", &resultLen, &status);
if(U_FAILURE(status) || result == NULL) {
- log_err("Failed to get resource ExemplarCharacters with %s\n", myErrorName(status));
+ log_err_status(status, "Failed to get resource ExemplarCharacters with %s\n", myErrorName(status));
}
ures_close(he);
status = U_ZERO_ERROR;
norway = ures_open(NULL, norwayNames[i], &status);
if(U_FAILURE(status)) {
- log_err("Failed to get resource with %s for %s\n", myErrorName(status), norwayNames[i]);
+ log_err_status(status, "Failed to get resource with %s for %s\n", myErrorName(status), norwayNames[i]);
continue;
}
realName = ures_getLocale(norway, &status);
}
else {
binResult=ures_getBinary(res, &len, &status);
- if(!U_SUCCESS(status) || binResult != NULL || len != 0) {
- log_err("Shouldn't get emptybin\n");
+ if(!U_SUCCESS(status) || len != 0) {
+ log_err("Couldn't get emptybin, or it's not empty\n");
}
}
else {
resArray=ures_getByIndex(res, 0, resArray, &status);
if(U_SUCCESS(status) || resArray != NULL){
- log_err("Shouldn't get emptyarray\n");
+ log_err("Shouldn't get emptyarray[0]\n");
}
}
else {
resArray=ures_getByIndex(res, 0, resArray, &status);
if(U_SUCCESS(status) || resArray != NULL){
- log_err("Shouldn't get emptytable\n");
+ log_err("Shouldn't get emptytable[0]\n");
}
}
status = U_ZERO_ERROR;
ures_close(ures_openU(NULL, "root", &status));
if(U_FAILURE(status)){
- log_err("ERROR: ures_openU() failed path = NULL with %s\n", myErrorName(status));
+ log_err_status(status, "ERROR: ures_openU() failed path = NULL with %s\n", myErrorName(status));
}
status = U_ILLEGAL_ARGUMENT_ERROR;
status = U_ZERO_ERROR;
teRes=ures_openU(utestdatapath, "te", &status);
if(U_FAILURE(status)){
- log_err("ERROR: ures_openU() failed path =%s with %s\n", austrdup(utestdatapath), myErrorName(status));
+ log_err_status(status, "ERROR: ures_openU() failed path =%s with %s\n", austrdup(utestdatapath), myErrorName(status));
return;
}
/*Test ures_getLocale() */
log_verbose("Testing version number for locale %s\n", locName);
resB = ures_open(NULL,locName, &status);
if (U_FAILURE(status)) {
- log_err("Resource bundle creation for locale %s failed.: %s\n", locName, myErrorName(status));
+ log_err_status(status, "Resource bundle creation for locale %s failed.: %s\n", locName, myErrorName(status));
ures_close(resB);
return;
}
log_verbose("The ures_getVersion(%s) tests begin : \n", U_ICUDATA_COLL);
locs = ures_openAvailableLocales(U_ICUDATA_COLL, &status);
if (U_FAILURE(status)) {
- log_err("enumeration of %s failed.: %s\n", U_ICUDATA_COLL, myErrorName(status));
+ log_err_status(status, "enumeration of %s failed.: %s\n", U_ICUDATA_COLL, myErrorName(status));
return;
}
fr_FR = ures_open(NULL, "fr_FR", &status);
if(U_FAILURE(status))
{
- log_err("Couldn't open fr_FR - %d\n", status);
+ log_err_status(status, "Couldn't open fr_FR - %s\n", u_errorName(status));
return;
}
ures_close(subResource);
/* and this is a Fallback, to fr */
- junk = tres_getString(fr_FR, -1, "Countries", &resultLen, &status);
+ junk = tres_getString(fr_FR, -1, "ExemplarCharacters", &resultLen, &status);
if(status != U_USING_FALLBACK_WARNING)
{
- log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get Countries from fr_FR, got %d\n",
+ log_data_err("Expected U_USING_FALLBACK_ERROR when trying to get ExemplarCharacters from fr_FR, got %d\n",
status);
}
UResourceBundle* myResB = ures_open(NULL,"no_NO_NY",&err);
UResourceBundle* resLocID = ures_getByKey(myResB, "Version", NULL, &err);
UResourceBundle* tResB;
+ UResourceBundle* zoneResource;
const UChar* version = NULL;
- static const UChar versionStr[] = { 0x0031, 0x002E, 0x0034, 0x0035, 0x0000};
+ static const UChar versionStr[] = { 0x0032, 0x002E, 0x0030, 0x002E, 0x0034, 0x0031, 0x002E, 0x0032, 0x0033, 0x0000};
if(err != U_ZERO_ERROR){
log_data_err("Expected U_ZERO_ERROR when trying to test no_NO_NY aliased to nn_NO for Version err=%s\n",u_errorName(err));
log_data_err("ures_getString(resLocID, &resultLen, &err) returned an unexpected version value. Expected '%s', but got '%s'\n",
x, g);
}
- tResB = ures_getByKey(myResB, "zoneStrings", NULL, &err);
+ zoneResource = ures_open(U_ICUDATA_ZONE, "no_NO_NY", &err);
+ tResB = ures_getByKey(zoneResource, "zoneStrings", NULL, &err);
if(err != U_USING_FALLBACK_WARNING){
log_err("Expected U_USING_FALLBACK_ERROR when trying to test no_NO_NY aliased with nn_NO_NY for zoneStrings err=%s\n",u_errorName(err));
}
+ ures_close(tResB);
+ ures_close(zoneResource);
ures_close(resLocID);
ures_close(myResB);
- ures_close(tResB);
-
}
}
/* testing referencing/composed alias */
uk = ures_findResource("ja/LocaleScript/2", uk, &status);
if((uk == NULL) || U_FAILURE(status)) {
- log_err("Couldn't findResource('ja/LocaleScript/2') err %s\n", u_errorName(status));
+ log_err_status(status, "Couldn't findResource('ja/LocaleScript/2') err %s\n", u_errorName(status));
goto cleanup;
}
string = tres_getString(tb, -1, NULL, &strLen, &status);
if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string\n");
+ log_err("Referencing alias didn't get the right string (1)\n");
}
string = tres_getString(aliasB, -1, "referencingalias", &strLen, &status);
if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string\n");
+ log_err("Referencing alias didn't get the right string (2)\n");
}
checkStatus(__LINE__, U_ZERO_ERROR, status);
if(U_FAILURE(status)) {
log_err("%s trying to get string via separate getters\n", u_errorName(status));
} else if(seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string\n");
+ log_err("Referencing alias didn't get the right string (3)\n");
}
string = tres_getString(tb, -1, NULL, &strLen, &status);
if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string\n");
+ log_err("Referencing alias didn't get the right string (4)\n");
}
/* test indexed aliasing */
tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
string = tres_getString(tb, -1, NULL, &strLen, &status);
- en = ures_findResource("en/zoneStrings/3/0", en, &status);
+ en = ures_findResource("/ICUDATA-zone/en/zoneStrings/3/0", en, &status);
sequence = tres_getString(en, -1, NULL, &seqLen, &status);
if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string\n");
+ log_err("Referencing alias didn't get the right string (5)\n");
}
}
/* test getting aliased string by index */
const char *key = NULL;
tb = ures_getByKey(aliasB, "testGetStringByKeyAliasing", tb, &status);
if(U_FAILURE(status)) {
- log_err("Couldn't get testGetStringByKeyAliasing resource\n");
- }
- for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = tres_getString(tb, -1, keys[i], &resultLen, &status);
- if(U_FAILURE(status)){
- log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
- continue;
- }
- uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
- log_err("Didn't get correct string while accesing alias table by key (%s)\n", keys[i]);
- }
- }
- for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = tres_getString(tb, i, NULL, &resultLen, &status);
- if(U_FAILURE(status)){
- log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
- continue;
- }
- uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
- log_err("Didn't get correct string while accesing alias table by index (%s)\n", strings[i]);
+ log_err("FAIL: Couldn't get testGetStringByKeyAliasing resource: %s\n", u_errorName(status));
+ } else {
+ for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+ result = tres_getString(tb, -1, keys[i], &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("(1) Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
+ uBufferLen = u_unescape(strings[i], uBuffer, 256);
+ if(resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ log_err("(1) Didn't get correct string while accessing alias table by key (%s)\n", keys[i]);
+ }
}
- }
- for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = ures_getNextString(tb, &resultLen, &key, &status);
- if(U_FAILURE(status)){
- log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
- continue;
+ for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+ result = tres_getString(tb, i, NULL, &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("(2) Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
+ uBufferLen = u_unescape(strings[i], uBuffer, 256);
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ log_err("(2) Didn't get correct string while accesing alias table by index (%s)\n", strings[i]);
+ }
}
- uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
- log_err("Didn't get correct string while iterating over alias table (%s)\n", strings[i]);
+ for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+ result = ures_getNextString(tb, &resultLen, &key, &status);
+ if(U_FAILURE(status)){
+ log_err("(3) Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
+ uBufferLen = u_unescape(strings[i], uBuffer, 256);
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ log_err("(3) Didn't get correct string while iterating over alias table (%s)\n", strings[i]);
+ }
}
}
tb = ures_getByKey(aliasB, "testGetStringByIndexAliasing", tb, &status);
if(U_FAILURE(status)) {
- log_err("Couldn't get testGetStringByIndexAliasing resource\n");
- }
- for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = tres_getString(tb, i, NULL, &resultLen, &status);
- if(U_FAILURE(status)){
- log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
- continue;
- }
- uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
- log_err("Didn't get correct string while accesing alias by index in an array (%s)\n", strings[i]);
- }
- }
- for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
- result = ures_getNextString(tb, &resultLen, &key, &status);
- if(U_FAILURE(status)){
- log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
- continue;
+ log_err("FAIL: Couldn't get testGetStringByIndexAliasing resource: %s\n", u_errorName(status));
+ } else {
+ for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+ result = tres_getString(tb, i, NULL, &resultLen, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
+ uBufferLen = u_unescape(strings[i], uBuffer, 256);
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ log_err("Didn't get correct string while accesing alias by index in an array (%s)\n", strings[i]);
+ }
}
- uBufferLen = u_unescape(strings[i], uBuffer, 256);
- if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
- log_err("Didn't get correct string while iterating over aliases in an array (%s)\n", strings[i]);
+ for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
+ result = ures_getNextString(tb, &resultLen, &key, &status);
+ if(U_FAILURE(status)){
+ log_err("Fetching the resource with key %s failed. Error: %s\n", keys[i], u_errorName(status));
+ continue;
+ }
+ uBufferLen = u_unescape(strings[i], uBuffer, 256);
+ if(result==NULL || resultLen != uBufferLen || u_strncmp(result, uBuffer, resultLen) != 0) {
+ log_err("Didn't get correct string while iterating over aliases in an array (%s)\n", strings[i]);
+ }
}
}
}
}
}
- t2 = ures_open(NULL, "sr", &status);
+ t2 = ures_open(U_ICUDATA_LANG, "sr", &status);
if(U_FAILURE(status)) {
- log_err("Couldn't open 'sr' resource bundle, error %s\n", u_errorName(status));
+ log_err_status(status, "Couldn't open 'sr' resource bundle, error %s\n", u_errorName(status));
log_data_err("No 'sr', no test - you have bigger problems than testing direct access. "
"You probably have no data! Aborting this test\n");
}
t2 = ures_getByKeyWithFallback(t2, "islamic-civil", t2, &status);
t2 = ures_getByKeyWithFallback(t2, "eras", t2, &status);
if(U_FAILURE(status)) {
- log_err("Didn't get Eras. I know they are there!\n");
+ log_err_status(status, "Didn't get Eras. I know they are there!\n");
}
status = U_ZERO_ERROR;
t = ures_getByKeyWithFallback(t, "gregorian", t, &status);
t = ures_getByKeyWithFallback(t, "AmPmMarkers", t, &status);
if(U_FAILURE(status)) {
- log_err("This resource should be available?\n");
+ log_err_status(status, "This resource should be available?\n");
}
status = U_ZERO_ERROR;
}
}
if(foundStandard == FALSE) {
- log_err("'standard' was not found in the keyword list.\n");
+ log_err_status(status, "'standard' was not found in the keyword list.\n");
}
uenum_close(kwVals);
if(U_FAILURE(status)) {
- log_err("err %s getting collation values\n", u_errorName(status));
+ log_err_status(status, "err %s getting collation values\n", u_errorName(status));
}
status = U_ZERO_ERROR;
#endif
}
}
if(foundStandard == FALSE) {
- log_err("'japanese' was not found in the calendar keyword list.\n");
+ log_err_status(status, "'japanese' was not found in the calendar keyword list.\n");
}
uenum_close(kwVals);
if(U_FAILURE(status)) {
- log_err("err %s getting calendar values\n", u_errorName(status));
+ log_err_status(status, "err %s getting calendar values\n", u_errorName(status));
}
}
resName, keyword, inLocale,
&gotAvail, truncate, &status);
if(U_FAILURE(status) || (len <= 0)) {
- log_err("FAIL: got len %d, err %s on #%d: %c\t%s\t%s\n",
+ log_err_status(status, "FAIL: got len %d, err %s on #%d: %c\t%s\t%s\n",
len, u_errorName(status),
i/3,expectAvail?'t':'f', inLocale, expectLocale);
} else {
"t", "zh_Hans_CN@collation=gb2312han", "zh@collation=gb2312han",
"t", "zh@collation=big5han", "zh@collation=big5han",
"t", "zh@collation=gb2312han", "zh@collation=gb2312han",
- "t", "hi_IN@collation=direct", "hi@collation=direct",
"t", "hi@collation=standard", "hi",
- "t", "hi@collation=direct", "hi@collation=direct",
- "f", "hi_AU@collation=direct;currency=CHF;calendar=buddhist", "hi@collation=direct",
"f", "hi_AU@collation=standard;currency=CHF;calendar=buddhist", "hi",
"t", "de_DE@collation=pinyin", "de", /* bug 4582 tests */
"f", "de_DE_BONN@collation=pinyin", "de",
static const char *calCases[] = {
/* avail locale equiv */
- "t", "en_US_POSIX", "en_US@calendar=gregorian",
- "f", "ja_JP_TOKYO", "ja_JP@calendar=gregorian",
+ "t", "en_US_POSIX", "en@calendar=gregorian",
+ "f", "ja_JP_TOKYO", "ja@calendar=gregorian",
"f", "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese",
"t", "sr@calendar=gregorian", "sr@calendar=gregorian",
"t", "en", "en@calendar=gregorian",
ures_close(res);
}
+
+static void TestCLDRVersion(void) {
+ UVersionInfo zeroVersion;
+ UVersionInfo testExpect;
+ UVersionInfo testCurrent;
+ UVersionInfo cldrVersion;
+ char tmp[200];
+ UErrorCode status = U_ZERO_ERROR;
+
+ /* setup the constant value */
+ u_versionFromString(zeroVersion, "0.0.0.0");
+
+ /* test CLDR value from API */
+ ulocdata_getCLDRVersion(cldrVersion, &status);
+ if(U_FAILURE(status)) {
+ /* the show is pretty much over at this point */
+ log_err_status(status, "FAIL: ulocdata_getCLDRVersion() returned %s\n", u_errorName(status));
+ return;
+ } else {
+ u_versionToString(cldrVersion, tmp);
+ log_info("ulocdata_getCLDRVersion() returned: '%s'\n", tmp);
+ }
+
+
+ /* setup from resource bundle */
+ {
+ UResourceBundle *res;
+ const char *testdatapath;
+
+ status = U_ZERO_ERROR;
+ testdatapath = loadTestData(&status);
+ if(U_FAILURE(status)) {
+ log_data_err("Could not load testdata.dat - %s\n", u_errorName(status));
+ return;
+ }
+
+ res = ures_openDirect(testdatapath, "root", &status);
+ if(U_FAILURE(status)) {
+ log_err("Unable to ures_open(testdata, \"\") - %s\n", u_errorName(status
+));
+ return;
+ }
+ ures_getVersionByKey(res, "ExpectCLDRVersionAtLeast", testExpect, &status);
+ ures_getVersionByKey(res, "CurrentCLDRVersion", testCurrent, &status);
+ ures_close(res);
+ if(U_FAILURE(status)) {
+ log_err("Unable to get test data for CLDR version - %s\n", u_errorName(status));
+ }
+ }
+ if(U_FAILURE(status)) return;
+
+
+ u_versionToString(testExpect,tmp);
+ log_verbose("(data) ExpectCLDRVersionAtLeast { %s }\n", tmp);
+ if(memcmp(cldrVersion, testExpect, sizeof(UVersionInfo)) < 0) {
+ log_data_err("CLDR version is too old, expect at least %s.", tmp);
+ }
+ u_versionToString(testCurrent,tmp);
+ log_verbose("(data) CurrentCLDRVersion { %s }\n", tmp);
+ switch(memcmp(cldrVersion, testCurrent, sizeof(UVersionInfo))) {
+ case 0: break; /* OK- current. */
+ case -1: log_info("CLDR version is behind 'current' (for testdata/root.txt) %s. Some things may fail.\n", tmp); break;
+ case 1: log_info("CLDR version is ahead of 'current' (for testdata/root.txt) %s. Some things may fail.\n", tmp); break;
+ }
+
+}