From: Rafał Szczekutek Date: Wed, 29 Jun 2016 16:58:24 +0000 (+0200) Subject: [UTC][base-utils][ACR-661][Updates for the Formattable module tests] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fa08b8904f795785609db94dad244c14407960f;p=test%2Ftct%2Fnative%2Fapi.git [UTC][base-utils][ACR-661][Updates for the Formattable module tests] These are the updates to the tests related to the last changes to the Formattable module sources. Change-Id: If764ae3d0a7368e51c3f6284ca898b4ceaab48b1 Signed-off-by: Rafał Szczekutek Signed-off-by: Damian Pietruchowski --- diff --git a/src/utc/base-utils/utc-capi-base-utils-formattable.c b/src/utc/base-utils/utc-capi-base-utils-formattable.c new file mode 100755 index 0000000..6bb8019 --- /dev/null +++ b/src/utc/base-utils/utc-capi-base-utils-formattable.c @@ -0,0 +1,2181 @@ +#include "assert.h" +#include +#include + +/** + * @function utc_capi_base_utils_formattable_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void utc_capi_base_utils_formattable_startup(void) +{ +} + +/** + * @function utc_capi_base_utils_formattable_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void utc_capi_base_utils_formattable_cleanup(void) +{ +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_string_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_string and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_string_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + const char *string_to_set = "Test string"; + + ret = i18n_formattable_set_string(formattable, string_to_set); + + char *set_string = NULL; + i18n_formattable_get_string(formattable, &set_string); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(strncmp(set_string, string_to_set, strlen(string_to_set)), 0); + assert_eq(type, I18N_FORMATTABLE_TYPE_STRING); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_string_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_string passing invalid formattable + * and checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_string_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + const char *string_to_set = "Test string"; + + ret = i18n_formattable_set_string(formattable, string_to_set); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_long_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_long and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_long_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int32_t long_to_set = 13; + + ret = i18n_formattable_set_long(formattable, long_to_set); + + int32_t set_long = 0; + i18n_formattable_get_long(formattable, &set_long); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(set_long, long_to_set); + assert_eq(type, I18N_FORMATTABLE_TYPE_LONG); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_long_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_long passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_long_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + int32_t long_to_set = 0; + + ret = i18n_formattable_set_long(formattable, long_to_set); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_int64_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_int64 and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_int64_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int64_t long_long_to_set = 13; + + ret = i18n_formattable_set_int64(formattable, long_long_to_set); + + int64_t set_long_long = 0; + i18n_formattable_get_int64(formattable, &set_long_long); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(set_long_long, long_long_to_set); + assert_eq(type, I18N_FORMATTABLE_TYPE_INT64); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_int64_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_int64 passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_int64_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + int64_t long_long_to_set = 0; + + ret = i18n_formattable_set_int64(formattable, long_long_to_set); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_double_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_double and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_double_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + double double_to_set = 13.0; + + ret = i18n_formattable_set_double(formattable, double_to_set); + + double set_double = 0.0; + i18n_formattable_get_double(formattable, &set_double); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(set_double, double_to_set); + assert_eq(type, I18N_FORMATTABLE_TYPE_DOUBLE); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_double_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_double passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_double_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + double double_to_set = 0.0; + + ret = i18n_formattable_set_double(formattable, double_to_set); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_date_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_date and checks whether function succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_date_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_udate date_to_set = 13.0; + + ret = i18n_formattable_set_date(formattable, date_to_set); + + double set_date = 0.0; + i18n_formattable_get_date(formattable, &set_date); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(set_date, date_to_set); + assert_eq(type, I18N_FORMATTABLE_TYPE_DATE); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_date_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_date passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_date_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_udate date_to_set = 0.0; + + ret = i18n_formattable_set_date(formattable, date_to_set); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_array_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_array and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_set_array_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element1 = NULL; + + ret = i18n_formattable_create_default(&array_element1); + + // TODO In case of error, the formattable handle won't be released here. + assert_neq(array_element1, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element2 = NULL; + + ret = i18n_formattable_create_default(&array_element2); + + assert_neq(array_element2, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element3 = NULL; + + ret = i18n_formattable_create_default(&array_element3); + + assert_neq(array_element3, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_to_set[] = {array_element1, array_element2, array_element3}; + + int32_t count = 3; + + ret = i18n_formattable_set_array(formattable, array_to_set, count); + + + i18n_formattable_h *set_array; + int32_t set_count = 0; + i18n_formattable_get_array(formattable, &set_array, &set_count); + + i18n_formattable_type_e type; + i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(set_count, count); + assert_eq(type, I18N_FORMATTABLE_TYPE_ARRAY); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_array_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_array passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_array_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_formattable_h array_element1 = NULL; + + ret = i18n_formattable_create_default(&array_element1); + + assert_neq(array_element1, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element2 = NULL; + + ret = i18n_formattable_create_default(&array_element2); + + assert_neq(array_element2, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element3 = NULL; + + ret = i18n_formattable_create_default(&array_element3); + + assert_neq(array_element3, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array[] = {array_element1, array_element2, array_element3}; + + int32_t count = 3; + + ret = i18n_formattable_set_array(formattable, array, count); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_array_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_array passing invalid array and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_array_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int32_t count = 0; + + ret = i18n_formattable_set_array(formattable, NULL, count); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_set_array_n3 + * @since_tizen 3.0 + * @description Calls i18n_formattable_set_array passing invalid count and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_set_array_n3(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element1 = NULL; + + ret = i18n_formattable_create_default(&array_element1); + + assert_neq(array_element1, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element2 = NULL; + + ret = i18n_formattable_create_default(&array_element2); + + assert_neq(array_element2, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element3 = NULL; + + ret = i18n_formattable_create_default(&array_element3); + + assert_neq(array_element3, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array[] = {array_element1, array_element2, array_element3}; + + int32_t count = -1; // Invalid parameter + + ret = i18n_formattable_set_array(formattable, array, count); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_element_at_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_element_at and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_element_at_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element1 = NULL; + + ret = i18n_formattable_create_default(&array_element1); + + assert_neq(array_element1, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element2 = NULL; + + ret = i18n_formattable_create_default(&array_element2); + + assert_neq(array_element2, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element3 = NULL; + + ret = i18n_formattable_create_default(&array_element3); + + assert_neq(array_element3, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + const i18n_formattable_h array[] = {array_element1, array_element2, array_element3}; + + int32_t count = 3; + + ret = i18n_formattable_set_array(formattable, array, count); + + assert_eq(ret, I18N_ERROR_NONE); + + int32_t index = 1; + + i18n_formattable_h element = NULL; + + ret = i18n_formattable_element_at(formattable, index, &element); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_neq(element, NULL); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_element_at_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_element_at passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_element_at_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + int32_t index = 0; + + i18n_formattable_h element = NULL; + + ret = i18n_formattable_element_at(formattable, index, &element); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_element_at_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_element_at passing invalid index and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_element_at_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int32_t index = -1; // Invalid parameter + + i18n_formattable_h element = NULL; + + ret = i18n_formattable_element_at(formattable, index, &element); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INDEX_OUTOFBOUNDS); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_element_at_n3 + * @since_tizen 3.0 + * @description Calls i18n_formattable_element_at passing invalid element and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_element_at_n3(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int32_t index = 0; + + ret = i18n_formattable_element_at(formattable, index, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_equal_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_equal and checks whether function succeeded. + */ +int utc_capi_base_utils_i18n_formattable_equal_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + bool equal; + + ret = i18n_formattable_equal(formattable, other, &equal); + + i18n_formattable_destroy(formattable); + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(equal, false); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_equal_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_equal passing invalid formattable and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_equal_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + bool equal; + + ret = i18n_formattable_equal(formattable, other, &equal); + + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_equal_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_equal passing invalid other and checks for an + * invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_equal_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; // Invalid parameter + + bool equal; + + ret = i18n_formattable_equal(formattable, other, &equal); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_equal_n3 + * @since_tizen 3.0 + * @description Calls i18n_formattable_equal passing invalid equal argument and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_equal_n3(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_equal(formattable, other, NULL); + + i18n_formattable_destroy(formattable); + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_not_equal_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_not_equal and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_not_equal_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + bool not_equal; + + ret = i18n_formattable_not_equal(formattable, other, ¬_equal); + + i18n_formattable_destroy(formattable); + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(not_equal, true); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_not_equal_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_not_equal passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_not_equal_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + bool not_equal; + + ret = i18n_formattable_not_equal(formattable, other, ¬_equal); + + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_not_equal_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_not_equal passing invalid other and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_not_equal_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; // Invalid parameter + + bool not_equal; + + ret = i18n_formattable_not_equal(formattable, other, ¬_equal); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_not_equal_n3 + * @since_tizen 3.0 + * @description Calls i18n_formattable_not_equal passing invalid not_equal + * argument and checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_not_equal_n3(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h other = NULL; + + ret = i18n_formattable_create_default(&other); + + assert_neq(other, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_not_equal(formattable, other, NULL); + + i18n_formattable_destroy(formattable); + i18n_formattable_destroy(other); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_is_numeric_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_is_numeric and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_is_numeric_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + bool is_numeric; + + ret = i18n_formattable_is_numeric(formattable, &is_numeric); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_neq(is_numeric, false); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_is_numeric_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_is_numeric passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_is_numeric_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + bool is_numeric; + + ret = i18n_formattable_is_numeric(formattable, &is_numeric); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_is_numeric_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_is_numeric passing invalid is_numeric + * and checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_is_numeric_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_is_numeric(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_type_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_type and checks whether function succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_type_p(void) { + + int ret; + + const char *test_string = "Test string"; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_char_string(test_string, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_type_e type; + + ret = i18n_formattable_get_type(formattable, &type); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(type, I18N_FORMATTABLE_TYPE_STRING); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_type_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_type passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_type_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_formattable_type_e type; + + ret = i18n_formattable_get_type(formattable, &type); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_type_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_type passing invalid type and checks for + * an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_type_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_get_type(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_string_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_string and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_string_p(void) { + + int ret; + + const char *test_string = "Test string"; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_char_string(test_string, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + char *value = NULL; + + ret = i18n_formattable_get_string(formattable, &value); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(strncmp(value, test_string, strlen(test_string)), 0); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_string_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_string passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_string_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + char *value = NULL; + + ret = i18n_formattable_get_string(formattable, &value); + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_string_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_string passing invalid value and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_string_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + char **value = NULL; // Invalid parameter + + ret = i18n_formattable_get_string(formattable, value); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_long_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_long and checks whether function succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_long_p(void) { + + int ret; + + int32_t l = 13; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_long(l, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int32_t value; + + ret = i18n_formattable_get_long(formattable, &value); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(value, l); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_long_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_long passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_long_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + int32_t value; + + ret = i18n_formattable_get_long(formattable, &value); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_long_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_long passing invalid value and checks for + * an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_long_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_get_long(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_int64_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_int64 and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_int64_p(void) { + + int ret; + + int64_t ll = 13; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_int64(ll, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + int64_t value = NULL; + + ret = i18n_formattable_get_int64(formattable, &value); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(value, ll); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_int64_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_int64 passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_int64_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + int64_t value; + + ret = i18n_formattable_get_int64(formattable, &value); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_int64_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_int64 passing invalid value and checks + * for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_int64_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_get_int64(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_double_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_double and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_double_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + double value; + + ret = i18n_formattable_get_double(formattable, &value); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_double_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_double passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_double_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + double value; + + ret = i18n_formattable_get_double(formattable, &value); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_double_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_double passing invalid pointer as a + * second parameter and checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_double_n2(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_get_double(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_date_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_date and checks whether function succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_date_p(void) { + + int ret; + + i18n_udate d = 13.0; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_udate(d, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_udate date; + + ret = i18n_formattable_get_date(formattable, &date); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_NONE); + assert_eq(date, d); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_date_n + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_date passing invalid formattable and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_date_n(void) { + + int ret; + + i18n_formattable_h formattable = NULL; // Invalid parameter + + i18n_udate date; + + ret = i18n_formattable_get_date(formattable, &date); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_date_n2 + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_date passing invalid date and + * checks for an invalid parameter error code. + */ +int utc_capi_base_utils_i18n_formattable_get_date_n2(void) { + + int ret; + + i18n_udate d = 13.0; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_with_udate(d, &formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + ret = i18n_formattable_get_date(formattable, NULL); + + i18n_formattable_destroy(formattable); + + assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); + + return 0; +} + +/** + * @testcase utc_capi_base_utils_i18n_formattable_get_array_p + * @since_tizen 3.0 + * @description Calls i18n_formattable_get_array and checks whether function + * succeeded. + */ +int utc_capi_base_utils_i18n_formattable_get_array_p(void) { + + int ret; + + i18n_formattable_h formattable = NULL; + + ret = i18n_formattable_create_default(&formattable); + + assert_neq(formattable, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element1 = NULL; + + ret = i18n_formattable_create_default(&array_element1); + + assert_neq(array_element1, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element2 = NULL; + + ret = i18n_formattable_create_default(&array_element2); + + assert_neq(array_element2, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array_element3 = NULL; + + ret = i18n_formattable_create_default(&array_element3); + + assert_neq(array_element3, NULL); + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h array[] = {array_element1, array_element2, array_element3}; + + int32_t count = 3; + + ret = i18n_formattable_set_array(formattable, array, count); + + assert_eq(ret, I18N_ERROR_NONE); + + i18n_formattable_h *ret_array; + + int32_t ret_count = 0; + + ret = i18n_formattable_get_array(formattable, &ret_array, &ret_count); + + assert_neq(ret_array, NULL); + assert_eq(ret_count, count); + + int i; + for(i=0;i