+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2008, International Business Machines Corporation and
+ * 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/uniset.h"
static const UChar kErrorUChars[] = { 0x45, 0x52, 0x52, 0x4f, 0x52, 0 };
static const int32_t kErrorLength = 5;
-static const int32_t kERROR_COUNT = -1234567;
//***************************************************************************************
//***************************************************************************************
-#define CONFIRM_EQ(actual, expected, myAction) if ((expected)==(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected) + "\n");}
-#define CONFIRM_GE(actual, expected, myAction) if ((actual)>=(expected)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected) + "\n");}
-#define CONFIRM_NE(actual, expected, myAction) if ((expected)!=(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected) + "\n");}
-
-#define CONFIRM_UErrorCode(actual, expected, myAction) if ((expected)==(actual)) { record_pass(myAction); } else { record_fail(myAction + (UnicodeString)" returned " + u_errorName(actual) + " instead of " + u_errorName(expected) + "\n"); }
+#define CONFIRM_EQ(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+ if ((expected)==(actual)) { \
+ record_pass(myAction); \
+ } else { \
+ record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of " + (expected) + "\n"); \
+ } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_GE(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+ if ((actual)>=(expected)) { \
+ record_pass(myAction); \
+ } else { \
+ record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x >= " + (expected) + "\n"); \
+ } \
+} UPRV_BLOCK_MACRO_END
+#define CONFIRM_NE(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+ if ((expected)!=(actual)) { \
+ record_pass(myAction); \
+ } else { \
+ record_fail(myAction + (UnicodeString)" returned " + (actual) + (UnicodeString)" instead of x != " + (expected) + "\n"); \
+ } \
+} UPRV_BLOCK_MACRO_END
+
+#define CONFIRM_UErrorCode(actual, expected, myAction) UPRV_BLOCK_MACRO_BEGIN { \
+ if ((expected)==(actual)) { \
+ record_pass(myAction); \
+ } else { \
+ record_fail(myAction + (UnicodeString)" returned " + u_errorName(actual) + " instead of " + u_errorName(expected) + "\n"); \
+ } \
+} UPRV_BLOCK_MACRO_END
//***************************************************************************************
{ "ne", NULL, U_USING_DEFAULT_WARNING, e_Root, { TRUE, FALSE, FALSE }, { TRUE, FALSE, FALSE } }
};
-static const int32_t bundles_count = sizeof(param) / sizeof(param[0]);
+static const 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 = "TestExemplar"; if (exec) TestExemplar(); break;
- case 3: name = "TestGetSize"; if (exec) TestGetSize(); break;
- case 4: name = "TestGetLocaleByType"; if (exec) TestGetLocaleByType(); break;
+ case 2: name = "TestGetSize"; if (exec) TestGetSize(); break;
+ case 3: name = "TestGetLocaleByType"; if (exec) TestGetLocaleByType(); break;
+#else
+ case 0: case 1: case 2: case 3: name = "skip"; break;
+#endif
+
+ case 4: name = "TestExemplar"; if (exec) TestExemplar(); 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;
}
const char* testdatapath=loadTestData(err);
if(U_FAILURE(err))
{
- dataerrln("[DATA] Could not load testdata.dat " + UnicodeString(testdatapath) + ", " + UnicodeString(u_errorName(err)));
+ dataerrln("Could not load testdata.dat " + UnicodeString(testdatapath) + ", " + UnicodeString(u_errorName(err)));
return;
}
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;
}
return;
}
- for(i = 0; i < (int32_t)(sizeof(test)/sizeof(test[0])); i++) {
+ for(i = 0; i < UPRV_LENGTHOF(test); i++) {
ResourceBundle res = rb.get(test[i].key, status);
if(U_FAILURE(status))
{
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;
}
- for(i = 0; i < (int32_t)(sizeof(test)/sizeof(test[0])); i++) {
+ for(i = 0; i < UPRV_LENGTHOF(test); i++) {
ResourceBundle rb(testdatapath, test[i].requestedLocale, status);
if(U_FAILURE(status))
{
status = U_ZERO_ERROR;
continue;
}
-
+
locale = res.getLocale(ULOC_REQUESTED_LOCALE, status);
- if(locale != Locale::getDefault()) {
+ if(U_SUCCESS(status) && locale != Locale::getDefault()) {
err("Expected requested locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
}
+ status = U_ZERO_ERROR;
locale = res.getLocale(ULOC_VALID_LOCALE, status);
if(strcmp(locale.getName(), test[i].validLocale) != 0) {
err("Expected valid locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
}
}
}
-
-//eof
-