mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-3499 Increase code coverage
X-SVN-Rev: 15430
This commit is contained in:
parent
c439ee1788
commit
7a13cf6dca
3 changed files with 56 additions and 17 deletions
|
@ -45,7 +45,6 @@ u_locbund_init(ULocaleBundle *result, const char *loc)
|
|||
len = (int32_t)strlen(loc);
|
||||
result->fLocale = (char*) uprv_malloc(len + 1);
|
||||
if(result->fLocale == 0) {
|
||||
uprv_free(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -119,19 +118,22 @@ u_locbund_close(ULocaleBundle *bundle)
|
|||
UNumberFormat*
|
||||
u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style)
|
||||
{
|
||||
UNumberFormat *formatAlias = NULL;
|
||||
if (style >= UNUM_IGNORE) {
|
||||
UNumberFormat **formatAlias = &bundle->fNumberFormat[style-1];
|
||||
if (*formatAlias == NULL) {
|
||||
formatAlias = bundle->fNumberFormat[style-1];
|
||||
if (formatAlias == NULL) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
*formatAlias = unum_open(style, NULL, 0, bundle->fLocale, NULL, &status);
|
||||
formatAlias = unum_open(style, NULL, 0, bundle->fLocale, NULL, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
unum_close(*formatAlias);
|
||||
*formatAlias = NULL;
|
||||
unum_close(formatAlias);
|
||||
formatAlias = NULL;
|
||||
}
|
||||
else {
|
||||
bundle->fNumberFormat[style-1] = formatAlias;
|
||||
}
|
||||
}
|
||||
return *formatAlias;
|
||||
}
|
||||
return NULL;
|
||||
return formatAlias;
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -1195,7 +1195,7 @@ static void TestTranslitOps(void)
|
|||
a = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, -1, NULL, &err);
|
||||
if(U_FAILURE(err))
|
||||
{
|
||||
log_err("Err opening transliterator %s\n", u_errorName(err));
|
||||
log_err("Error opening transliterator %s\n", u_errorName(err));
|
||||
u_fclose(f);
|
||||
return;
|
||||
}
|
||||
|
@ -1205,16 +1205,41 @@ static void TestTranslitOps(void)
|
|||
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
||||
if(U_FAILURE(err))
|
||||
{
|
||||
log_err("Err setting transliterator %s\n", u_errorName(err));
|
||||
log_err("Error setting transliterator %s\n", u_errorName(err));
|
||||
u_fclose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
if(b != NULL)
|
||||
{
|
||||
log_err("Err, a transliterator was already set!\n");
|
||||
log_err("Error, a transliterator was already set!\n");
|
||||
}
|
||||
|
||||
b = u_fsettransliterator(NULL, U_WRITE, a, &err);
|
||||
if(err != U_ILLEGAL_ARGUMENT_ERROR)
|
||||
{
|
||||
log_err("Error setting transliterator on NULL file err=%s\n", u_errorName(err));
|
||||
}
|
||||
|
||||
if(b != a)
|
||||
{
|
||||
log_err("Error getting the same transliterator was not returned on NULL file\n");
|
||||
}
|
||||
|
||||
err = U_FILE_ACCESS_ERROR;
|
||||
b = u_fsettransliterator(f, U_WRITE, a, &err);
|
||||
if(err != U_FILE_ACCESS_ERROR)
|
||||
{
|
||||
log_err("Error setting transliterator on error status err=%s\n", u_errorName(err));
|
||||
}
|
||||
|
||||
if(b != a)
|
||||
{
|
||||
log_err("Error getting the same transliterator on error status\n");
|
||||
}
|
||||
err = U_ZERO_ERROR;
|
||||
|
||||
|
||||
log_verbose("un-setting transliterator (setting to null)\n");
|
||||
c = u_fsettransliterator(f, U_WRITE, NULL, &err);
|
||||
if(U_FAILURE(err))
|
||||
|
|
24
icu4c/source/test/testdata/icuio.txt
vendored
24
icu4c/source/test/testdata/icuio.txt
vendored
|
@ -181,24 +181,36 @@ icuio {
|
|||
{
|
||||
"%*S%S", "1234 5678", "S", "5678"
|
||||
}
|
||||
{
|
||||
"%d", "1234 5678", "4", "4D2"
|
||||
}
|
||||
{
|
||||
"%*d%d", "1234 5678", "4", "162E"
|
||||
}
|
||||
{
|
||||
"%hd", "1234 5678", "2", "4D2"
|
||||
}
|
||||
{
|
||||
"%*hd%hd", "1234 5678", "2", "162E"
|
||||
}
|
||||
{
|
||||
"%d", "1234 5678", "4", "4D2"
|
||||
}
|
||||
{
|
||||
"%ld", "1234 5678", "4", "4D2"
|
||||
}
|
||||
{
|
||||
"%lld", "1311768467463790320", "8", "123456789abcdef0"
|
||||
}
|
||||
{
|
||||
"%*d%d", "1234 5678", "4", "162E"
|
||||
}
|
||||
{
|
||||
"%x", "abcd ef01", "4", "abcd"
|
||||
}
|
||||
{
|
||||
"%*hx%hx", "abcd ef01", "2", "ef01"
|
||||
}
|
||||
{
|
||||
"%lx", "abcdef01", "4", "abcdef01"
|
||||
}
|
||||
{
|
||||
"%llx", "123456789abcdef0", "8", "123456789abcdef0"
|
||||
}
|
||||
{
|
||||
"%[abce]", "abcd ef01", "S", "abc"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue