+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
- * Copyright (c) 1997-2008, International Business Machines
+ * 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/resbund.h"
{ "ne", 0, U_USING_DEFAULT_WARNING, e_Root, { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } }
};
-static int32_t bundles_count = sizeof(param) / sizeof(param[0]);
+static int32_t bundles_count = UPRV_LENGTHOF(param);
//***************************************************************************************
{
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;
}
{
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 = "TestIteration"; if (exec) TestIteration(); break;
case 3: name = "TestOtherAPI"; if(exec) TestOtherAPI(); break;
case 4: name = "TestNewTypes"; if(exec) TestNewTypes(); break;
+#else
+ case 0: case 1: case 2: case 3: case 4: name = "skip"; break;
+#endif
+
case 5: name = "TestGetByFallback"; if(exec) TestGetByFallback(); break;
default: name = ""; break; //needed to end loop
}
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;
}
testdatapath=loadTestData(err);
if(U_FAILURE(err))
{
- dataerrln("[DATA] Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+ dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
return;
}
testdatapath=loadTestData(err);
if(U_FAILURE(err))
{
- dataerrln("[DATA] Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+ dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
return;
}
UnicodeString action;
- for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
+ for(i=0; i<UPRV_LENGTHOF(data); i=i+2){
action = "te_IN";
action +=".get(";
action += data[i];
if(U_FAILURE(err))
{
- dataerrln("[DATA] Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
+ dataerrln("Could not load testdata.dat %s " + UnicodeString(u_errorName(err)));
return;
}
ResourceBundle defaultresource(err);
ResourceBundle explicitdefaultresource(NULL, Locale::getDefault(), err);
if(U_FAILURE(err)){
- errln("Construction of default resourcebundle failed");
+ errcheckln(err, "Construction of default resourcebundle failed - %s", u_errorName(err));
return;
}
// You can't compare the default locale to the resolved locale in the
UnicodeString action;
- for(i=0; i<sizeof(data)/sizeof(data[0]); i=i+2){
+ for(i=0; i<UPRV_LENGTHOF(data); i=i+2){
action = "te_IN";
action +=".get(";
action += data[i];
}
}
}
+
+ // Check that ures_getUnicodeString() & variants return a bogus string if failure.
+ // Same relevant code path whether the failure code is passed in
+ // or comes from a lookup error.
+ UErrorCode failure = U_INTERNAL_PROGRAM_ERROR;
+ assertTrue("ures_getUnicodeString(failure).isBogus()",
+ ures_getUnicodeString(testCAPI, &failure).isBogus());
+ assertTrue("ures_getNextUnicodeString(failure).isBogus()",
+ ures_getNextUnicodeString(testCAPI, NULL, &failure).isBogus());
+ assertTrue("ures_getUnicodeStringByIndex(failure).isBogus()",
+ ures_getUnicodeStringByIndex(testCAPI, 999, &failure).isBogus());
+ assertTrue("ures_getUnicodeStringByKey(failure).isBogus()",
+ ures_getUnicodeStringByKey(testCAPI, "bogus key", &failure).isBogus());
+
ures_close(temp);
ures_close(rowbundle);
ures_close(bundle);
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;
}
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;
}
ResourceBundle bundle(testdatapath, Locale("te_IN"),status);
UnicodeString emptyStr = theBundle.getStringEx("emptystring", status);
- if(!emptyStr.length()==0) {
+ if(emptyStr.length() != 0) {
logln("Empty string returned invalid value\n");
}
heRes.getWithFallback("calendar", status).getWithFallback("islamic-civil", status).getWithFallback("eras", status);
if(U_FAILURE(status)) {
- errln("Didn't get Islamic Eras. I know they are there!\n");
+ dataerrln("Didn't get Islamic Eras. I know they are there! - %s", u_errorName(status));
}
status = U_ZERO_ERROR;