From: DongHun Kwak Date: Fri, 15 Apr 2022 03:09:00 +0000 (+0900) Subject: fix: fix invalid cleanup logic X-Git-Tag: accepted/tizen/unified/20220530.140619~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5cbe5f11fe3d0fbe080ee10df7ae86ba0fffb892;p=platform%2Fcore%2Fapi%2Fbase-utils.git fix: fix invalid cleanup logic - does not called i18n_uidna_destroy() at cleanup Change-Id: Ia0a863cc7dac0ca85cb658c4d704ce6b2db9292a --- diff --git a/tests/utc-capi-base-utils-uidna.c b/tests/utc-capi-base-utils-uidna.c index bde708c..b00eff8 100644 --- a/tests/utc-capi-base-utils-uidna.c +++ b/tests/utc-capi-base-utils-uidna.c @@ -17,31 +17,36 @@ #include #include -#define I18N_UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) +#define I18N_UPRV_LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0])) static int ret = I18N_ERROR_NONE; static i18n_uidna_h uidna; /** -* @function utc_capi_base_utils_uidna_startup -* @description Called before each test -* @parameter NA -* @return NA -*/ + * @function utc_capi_base_utils_uidna_startup + * @description Called before each test + * @parameter NA + * @return NA + */ void utc_capi_base_utils_uidna_startup(void) { + uidna = NULL; + ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); } /** -* @function utc_capi_base_utils_uidna_cleanup -* @description Called after each test -* @parameter NA -* @return NA -*/ + * @function utc_capi_base_utils_uidna_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ void utc_capi_base_utils_uidna_cleanup(void) { - if (!uidna) + if (uidna != NULL) + { i18n_uidna_destroy(uidna); + uidna = NULL; + } } /** @@ -51,15 +56,12 @@ void utc_capi_base_utils_uidna_cleanup(void) */ int utc_capi_base_utils_i18n_uidna_label_to_ascii_p(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_ascii(uidna, fA_sharps16, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -74,14 +76,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_ascii_p(void) */ int utc_capi_base_utils_i18n_uidna_label_to_ascii_n(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_ascii(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -104,14 +103,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_ascii_n(void) */ int utc_capi_base_utils_i18n_uidna_label_to_unicode_p(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_unicode(uidna, fA_sharps16, i18n_ustring_get_length(fA_sharps16), dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -126,14 +122,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_unicode_p(void) */ int utc_capi_base_utils_i18n_uidna_label_to_unicode_n(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_unicode(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -156,15 +149,12 @@ int utc_capi_base_utils_i18n_uidna_label_to_unicode_n(void) */ int utc_capi_base_utils_i18n_uidna_name_to_ascii_p(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_ascii(uidna, fA_sharps16, i18n_ustring_get_length(fA_sharps16), dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -179,14 +169,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_ascii_p(void) */ int utc_capi_base_utils_i18n_uidna_name_to_ascii_n(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_ascii(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -209,14 +196,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_ascii_n(void) */ int utc_capi_base_utils_i18n_uidna_name_to_unicode_p(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode(uidna, fA_sharps16, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -231,14 +215,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_unicode_p(void) */ int utc_capi_base_utils_i18n_uidna_name_to_unicode_n(void) { - static const i18n_uchar fA_sharps16[] = { 0x66, 0x41, 0xdf, 0 }; + static const i18n_uchar fA_sharps16[] = {0x66, 0x41, 0xdf, 0}; i18n_uchar dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -261,14 +242,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_unicode_n(void) */ int utc_capi_base_utils_i18n_uidna_label_to_ascii_UTF8_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_ascii_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -283,14 +261,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_ascii_UTF8_p(void) */ int utc_capi_base_utils_i18n_uidna_label_to_ascii_UTF8_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_ascii_UTF8(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -313,14 +288,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_ascii_UTF8_n(void) */ int utc_capi_base_utils_i18n_uidna_label_to_unicode_UTF8_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_unicode_UTF8(uidna, fA_sharps8, (int32_t)strlen(fA_sharps8), dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -335,14 +307,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_unicode_UTF8_p(void) */ int utc_capi_base_utils_i18n_uidna_label_to_unicode_UTF8_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_label_to_unicode_UTF8(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -365,14 +334,11 @@ int utc_capi_base_utils_i18n_uidna_label_to_unicode_UTF8_n(void) */ int utc_capi_base_utils_i18n_uidna_name_to_ascii_UTF8_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_ascii_UTF8(uidna, fA_sharps8, (int32_t)strlen(fA_sharps8), dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -387,14 +353,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_ascii_UTF8_p(void) */ int utc_capi_base_utils_i18n_uidna_name_to_ascii_UTF8_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_ascii_UTF8(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -417,14 +380,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_ascii_UTF8_n(void) */ int utc_capi_base_utils_i18n_uidna_name_to_unicode_UTF8_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); assert_eq(length, 4); @@ -439,14 +399,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_unicode_UTF8_p(void) */ int utc_capi_base_utils_i18n_uidna_name_to_unicode_UTF8_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, NULL, -3, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -469,14 +426,11 @@ int utc_capi_base_utils_i18n_uidna_name_to_unicode_UTF8_n(void) */ int utc_capi_base_utils_i18n_uidna_info_get_is_trans_different_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); @@ -495,14 +449,11 @@ int utc_capi_base_utils_i18n_uidna_info_get_is_trans_different_p(void) */ int utc_capi_base_utils_i18n_uidna_info_get_is_trans_different_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); @@ -523,14 +474,11 @@ int utc_capi_base_utils_i18n_uidna_info_get_is_trans_different_n(void) */ int utc_capi_base_utils_i18n_uidna_info_get_errors_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); @@ -548,14 +496,11 @@ int utc_capi_base_utils_i18n_uidna_info_get_errors_p(void) */ int utc_capi_base_utils_i18n_uidna_info_get_errors_n(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); @@ -576,14 +521,11 @@ int utc_capi_base_utils_i18n_uidna_info_get_errors_n(void) */ int utc_capi_base_utils_i18n_uidna_info_destroy_p(void) { - static const char fA_sharps8[] = { 0x66, 0x41, (char)0xc3, (char)0x9f, 0 }; + static const char fA_sharps8[] = {0x66, 0x41, (char)0xc3, (char)0x9f, 0}; char dest[10]; i18n_uidna_info_h info; int32_t length; - ret = i18n_uidna_create(I18N_UIDNA_DEFAULT, &uidna); - assert_eq(ret, I18N_ERROR_NONE); - ret = i18n_uidna_name_to_unicode_UTF8(uidna, fA_sharps8, -1, dest, I18N_UPRV_LENGTHOF(dest), &info, &length); assert_eq(ret, I18N_ERROR_NONE); @@ -605,4 +547,3 @@ int utc_capi_base_utils_i18n_uidna_info_destroy_n(void) return 0; } -