ICU-868 Better testing of new API

X-SVN-Rev: 9282
This commit is contained in:
George Rhoten 2002-07-22 21:05:17 +00:00
parent 911da04bff
commit 85012434a2

View File

@ -101,7 +101,7 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex
UErrorCode err = U_ZERO_ERROR; UErrorCode err = U_ZERO_ERROR;
UEnumeration *myEnum = ucnv_openStandardNames(name, standard, &err); UEnumeration *myEnum = ucnv_openStandardNames(name, standard, &err);
int32_t enumCount = uenum_count(myEnum, &err); int32_t enumCount = uenum_count(myEnum, &err);
int32_t idx; int32_t idx, repeatTimes = 3;
if (size != enumCount) { if (size != enumCount) {
log_err("FAIL: different size arrays. Got %d. Expected %d\n", enumCount, size); log_err("FAIL: different size arrays. Got %d. Expected %d\n", enumCount, size);
return 0; return 0;
@ -111,15 +111,23 @@ static UBool doTestNames(const char *name, const char *standard, const char **ex
return 0; return 0;
} }
log_verbose("\n%s %s\n", name, standard); log_verbose("\n%s %s\n", name, standard);
for (idx = 0; idx < enumCount; idx++) { while (repeatTimes-- > 0) {
const char *enumName = uenum_next(myEnum, NULL, &err); for (idx = 0; idx < enumCount; idx++) {
const char *testName = expected[idx]; const char *enumName = uenum_next(myEnum, NULL, &err);
if (uprv_strcmp(enumName, testName) != 0 || U_FAILURE(err)) { const char *testName = expected[idx];
log_err("FAIL: uenum_next(%d) == \"%s\". expected \"%s\", error=%s\n", if (uprv_strcmp(enumName, testName) != 0 || U_FAILURE(err)) {
idx, enumName, testName, u_errorName(err)); log_err("FAIL: uenum_next(%d) == \"%s\". expected \"%s\", error=%s\n",
idx, enumName, testName, u_errorName(err));
}
log_verbose("%s\n", enumName);
err = U_ZERO_ERROR;
}
uenum_reset(myEnum, &err);
if (U_FAILURE(err)) {
log_err("FAIL: uenum_reset() for %s{%s} failed with %s\n",
name, standard, u_errorName(err));
err = U_ZERO_ERROR;
} }
log_verbose("%s\n", enumName);
err = U_ZERO_ERROR;
} }
uenum_close(myEnum); uenum_close(myEnum);
return 1; return 1;