#include <utils_i18n.h>
#include <string.h>
-#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 int i;
*/
void utc_capi_base_utils_ucnv_cleanup(void)
{
- if (!cnv) {
+ if (!cnv)
+ {
i18n_ucnv_destroy(cnv);
cnv = NULL;
}
}
-
/**
* @testcase utc_capi_base_utils_i18n_ucnv_get_max_bytes_for_string_p
* @since_tizen 6.0
*/
int utc_capi_base_utils_i18n_ucnv_compare_names_p(void)
{
- static const char *equalUTF8[]={ "UTF-8", "utf_8", "u*T@f08", "Utf 8" };
+ static const char *equalUTF8[] = {"UTF-8", "utf_8", "u*T@f08", "Utf 8"};
int result;
- for(i = 0; i<3; ++i) {
- result = i18n_ucnv_compare_names(equalUTF8[i], equalUTF8[i+1]);
+ for (i = 0; i < 3; ++i)
+ {
+ result = i18n_ucnv_compare_names(equalUTF8[i], equalUTF8[i + 1]);
assert_eq(result, 0);
}
*/
int utc_capi_base_utils_i18n_ucnv_compare_names_n1(void)
{
- static const char equalUTF8[]={ "UTF-8" };
+ static const char equalUTF8[] = {"UTF-8"};
int result;
result = i18n_ucnv_compare_names(equalUTF8, NULL);
*/
int utc_capi_base_utils_i18n_ucnv_compare_names_n2(void)
{
- static const char equalUTF8[]={ "UTF-8" };
+ static const char equalUTF8[] = {"UTF-8"};
int result;
result = i18n_ucnv_compare_names(NULL, equalUTF8);
*/
int utc_capi_base_utils_i18n_ucnv_create_unicode_n1(void)
{
- const char *illegal_name_chars={ "ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943"};
+ const char *illegal_name_chars = {"ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943 ibm-943"};
i18n_uchar illegal_name[100];
i18n_ustring_copy_ua(illegal_name, "");
i18n_ustring_copy_ua(illegal_name, illegal_name_chars);
*/
int utc_capi_base_utils_i18n_ucnv_create_unicode_n2(void)
{
- i18n_uchar first_sorted_name[]={ 0x0021, 0x0000}; /* ! */
+ i18n_uchar first_sorted_name[] = {0x0021, 0x0000}; /* ! */
ret = i18n_ucnv_create_unicode(first_sorted_name, &cnv);
assert_eq(ret, I18N_ERROR_FILE_ACCESS);
*/
int utc_capi_base_utils_i18n_ucnv_create_ccsid_p(void)
{
- int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
+ int32_t ccsids[] = {37, 850, 943, 949, 950, 1047, 1252, 1392, 33722};
- for(int i = 0; i<9; ++i) {
+ for (int i = 0; i < 9; ++i)
+ {
ret = i18n_ucnv_create_ccsid(ccsids[i], I18N_UCNV_IBM, &cnv);
assert_eq(ret, I18N_ERROR_NONE);
}
}
/**
+ * @testcase utc_capi_base_utils_i18n_ucnv_create_package_n
+ * @since_tizen 6.0
+ * @description Calls i18n_ucnv_create_package with invalid data.
+ */
+int utc_capi_base_utils_i18n_ucnv_create_package_n(void)
+{
+ i18n_ucnv_h converter;
+
+ ret = i18n_ucnv_create_package("", "", &converter);
+
+ assert_eq(converter, NULL);
+ assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
+
+ return 0;
+}
+
+/**
* @testcase utc_capi_base_utils_i18n_ucnv_create_ccsid_n1
* @since_tizen 6.0
* @description Calls i18n_ucnv_create_ccsid and checks whether function succeeded.
*/
int utc_capi_base_utils_i18n_ucnv_create_ccsid_n1(void)
{
- ret = i18n_ucnv_create_ccsid(37, (i18n_ucnv_platform_e) (I18N_UCNV_IBM + 1), &cnv);
+ ret = i18n_ucnv_create_ccsid(37, (i18n_ucnv_platform_e)(I18N_UCNV_IBM + 1), &cnv);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
*/
int utc_capi_base_utils_i18n_ucnv_create_ccsid_n2(void)
{
- ret = i18n_ucnv_create_ccsid(37, (i18n_ucnv_platform_e) (I18N_UCNV_UNKNOWN - 1), &cnv);
+ ret = i18n_ucnv_create_ccsid(37, (i18n_ucnv_platform_e)(I18N_UCNV_UNKNOWN - 1), &cnv);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
{
char buffer[16];
int8_t len8;
- static const i18n_uchar sub[5] = { 0x61, 0x62, 0x63, 0x64, 0x65 };
+ static const i18n_uchar sub[5] = {0x61, 0x62, 0x63, 0x64, 0x65};
ret = i18n_ucnv_create("ISO-8859-1", &cnv);
assert_eq(ret, I18N_ERROR_NONE);
{
char buffer[16];
int8_t len8;
- static const i18n_uchar sub[5] = { 0x61, 0x62, 0x63, 0x64, 0x65 };
+ static const i18n_uchar sub[5] = {0x61, 0x62, 0x63, 0x64, 0x65};
ret = i18n_ucnv_create("ISO-8859-1", &cnv);
assert_eq(ret, I18N_ERROR_NONE);
*/
int utc_capi_base_utils_i18n_ucnv_set_subst_string_n1(void)
{
- static const i18n_uchar sub[5] = { 0x61, 0x62, 0x63, 0x64, 0x65 };
+ static const i18n_uchar sub[5] = {0x61, 0x62, 0x63, 0x64, 0x65};
ret = i18n_ucnv_set_subst_string(NULL, sub, I18N_UPRV_LENGTHOF(sub));
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
*/
int utc_capi_base_utils_i18n_ucnv_set_subst_string_n2(void)
{
- static const i18n_uchar sub[5] = { 0x61, 0x62, 0x63, 0x64, 0x65 };
+ static const i18n_uchar sub[5] = {0x61, 0x62, 0x63, 0x64, 0x65};
ret = i18n_ucnv_create("ISO-8859-1", &cnv);
assert_eq(ret, I18N_ERROR_NONE);
int32_t capacity = 0;
int32_t display_name_len;
ret = i18n_ucnv_get_display_name(cnv, "ko_KR", display_name, capacity, &display_name_len);
- if(I18N_ERROR_BUFFER_OVERFLOW == ret) {
+ if (I18N_ERROR_BUFFER_OVERFLOW == ret)
+ {
display_name = (i18n_uchar *)malloc((display_name_len + 1) * sizeof(i18n_uchar));
ret = i18n_ucnv_get_display_name(cnv, "ko_KR", display_name, display_name_len + 1, &display_name_len);
assert_eq(ret, I18N_ERROR_NONE);
int utc_capi_base_utils_i18n_ucnv_get_name_p(void)
{
static const char *const names[] = {
- "Unicode", "UTF-16",
- "UnicodeBigUnmarked", "UTF-16BE",
- "UnicodeBig", "UTF-16BE,version=1",
- "UnicodeLittleUnmarked", "UTF-16LE",
- "UnicodeLittle", "UTF-16LE,version=1",
- "x-UTF-16LE-BOM", "UTF-16LE,version=1"
- };
-
- for(int i = 0; i < I18N_UPRV_LENGTHOF(names); i += 2) {
+ "Unicode", "UTF-16",
+ "UnicodeBigUnmarked", "UTF-16BE",
+ "UnicodeBig", "UTF-16BE,version=1",
+ "UnicodeLittleUnmarked", "UTF-16LE",
+ "UnicodeLittle", "UTF-16LE,version=1",
+ "x-UTF-16LE-BOM", "UTF-16LE,version=1"};
+
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(names); i += 2)
+ {
ret = i18n_ucnv_create(names[i], &cnv);
assert_eq(ret, I18N_ERROR_NONE);
const char *name;
ret = i18n_ucnv_get_name(cnv, &name);
assert_eq(ret, I18N_ERROR_NONE);
- assert_eq(strcmp(name, names[i+1]), 0);
+ assert_eq(strcmp(name, names[i + 1]), 0);
}
assert_eq(ret, I18N_ERROR_NONE);
*/
int utc_capi_base_utils_i18n_ucnv_get_ccsid_p(void)
{
- int32_t ccsids[]={ 37, 850, 943, 949, 950, 1047, 1252, 1392, 33722 };
+ int32_t ccsids[] = {37, 850, 943, 949, 950, 1047, 1252, 1392, 33722};
- for(int i = 0; i < I18N_UPRV_LENGTHOF(ccsids); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(ccsids); ++i)
+ {
ret = i18n_ucnv_create_ccsid(ccsids[i], I18N_UCNV_IBM, &cnv);
assert_eq(ret, I18N_ERROR_NONE);
return 0;
}
-
/**
* @testcase utc_capi_base_utils_i18n_ucnv_from_uchars_n3
* @since_tizen 6.0
return 0;
}
-
/**
* @testcase utc_capi_base_utils_i18n_ucnv_from_uchars_n4
* @since_tizen 6.0
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
*/
int utc_capi_base_utils_i18n_ucnv_get_next_uchar_p(void)
{
- const char source_data[] = { (char)0xa2, (char)0xae, (char)0xa2 };
+ const char source_data[] = {(char)0xa2, (char)0xae, (char)0xa2};
const char *source = source_data;
const char *source_limit = source_data + sizeof(source_data);
i18n_uchar32 result1, result2;
*/
int utc_capi_base_utils_i18n_ucnv_get_next_uchar_n1(void)
{
- const char source_data[] = { (char)0xa2, (char)0xae, (char)0xa2 };
+ const char source_data[] = {(char)0xa2, (char)0xae, (char)0xa2};
const char *source = source_data;
const char *source_limit = source_data + sizeof(source_data);
i18n_uchar32 result3;
int utc_capi_base_utils_i18n_ucnv_get_next_uchar_n2(void)
{
i18n_uchar32 result3;
- const char source_data[] = { (char)0xa2, (char)0xae, (char)0xa2 };
+ const char source_data[] = {(char)0xa2, (char)0xae, (char)0xa2};
const char *source_limit = source_data + sizeof(source_data);
ret = i18n_ucnv_create("ibm-1363", &cnv);
ret = i18n_ucnv_create("Shift-JIS", &cnv2);
assert_eq(ret, I18N_ERROR_NONE);
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer+sizeof(target_buffer), &src, NULL, NULL, NULL, NULL, NULL, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer + sizeof(target_buffer), &src, NULL, NULL, NULL, NULL, NULL, true, true);
assert_eq(ret, I18N_ERROR_NONE);
return 0;
assert_eq(ret, I18N_ERROR_NONE);
pivot_source = pivot_target = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer+sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer + sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
assert_eq(ret, I18N_ERROR_NONE);
pivot_target = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer+sizeof(target_buffer), &src, NULL, pivot_buffer, NULL, &pivot_target, pivot_buffer+1, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer + sizeof(target_buffer), &src, NULL, pivot_buffer, NULL, &pivot_target, pivot_buffer + 1, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
assert_eq(ret, I18N_ERROR_NONE);
pivot_source = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer+sizeof(target_buffer), NULL, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer+1, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer + sizeof(target_buffer), NULL, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer + 1, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
src = src_buffer;
pivot_source = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer+sizeof(target_buffer), &src, NULL, NULL, &pivot_source, &pivot_target, pivot_buffer+1, true, false);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, &target, target_buffer + sizeof(target_buffer), &src, NULL, NULL, &pivot_source, &pivot_target, pivot_buffer + 1, true, false);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
src = src_buffer;
pivot_source = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, cnv1, NULL, target_buffer+sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, cnv1, NULL, target_buffer + sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
src = src_buffer;
pivot_source = pivot_buffer;
- ret = i18n_ucnv_convert_ex(NULL, cnv1, &target, target_buffer+sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
+ ret = i18n_ucnv_convert_ex(NULL, cnv1, &target, target_buffer + sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
src = src_buffer;
pivot_source = pivot_buffer;
- ret = i18n_ucnv_convert_ex(cnv2, NULL, &target, target_buffer+sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
+ ret = i18n_ucnv_convert_ex(cnv2, NULL, &target, target_buffer + sizeof(target_buffer), &src, NULL, pivot_buffer, &pivot_source, &pivot_target, pivot_buffer, true, true);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
{
int32_t target_limit = 0, source_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- const uint8_t expected_target[]={ 0x00, 0x37, 0x2d, 0x2e, 0x0e, 0x49, 0x62, 0x0f, 0x00};
- char *target=0;
- source_limit=I18N_UPRV_LENGTHOF(source);
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ const uint8_t expected_target[] = {0x00, 0x37, 0x2d, 0x2e, 0x0e, 0x49, 0x62, 0x0f, 0x00};
+ char *target = 0;
+ source_limit = I18N_UPRV_LENGTHOF(source);
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char*)source, source_limit, &target_capacity);
- if(ret == I18N_ERROR_BUFFER_OVERFLOW) {
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char *)source, source_limit, &target_capacity);
+ if (ret == I18N_ERROR_BUFFER_OVERFLOW)
+ {
target_limit = target_capacity + 1;
- target = (char *)malloc(sizeof(char) *target_limit);
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, target_limit, (const char*)source, source_limit, &target_capacity);
+ target = (char *)malloc(sizeof(char) * target_limit);
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, target_limit, (const char *)source, source_limit, &target_capacity);
}
assert_eq(ret, I18N_ERROR_NONE);
- for(int i = 0; i < target_capacity; ++i)
+ for (int i = 0; i < target_capacity; ++i)
assert_eq(target[i], expected_target[i]);
return 0;
{
int32_t target_limit = 0, source_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- source_limit=I18N_UPRV_LENGTHOF(source);
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ source_limit = I18N_UPRV_LENGTHOF(source);
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char*)source, source_limit, &target_capacity);
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char *)source, source_limit, &target_capacity);
assert_eq(ret, I18N_ERROR_BUFFER_OVERFLOW);
return 0;
{
int32_t target_limit = 0, source_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- char *target=0;
- source_limit=I18N_UPRV_LENGTHOF(source);
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ char *target = 0;
+ source_limit = I18N_UPRV_LENGTHOF(source);
target_limit = target_capacity + 1;
target = (char *)malloc(sizeof(char) * target_limit);
{
int32_t target_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- char *target=0;
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ char *target = 0;
target_limit = target_capacity + 1;
target = (char *)malloc(sizeof(char) * target_limit);
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, target_limit, (const char*)source, -2, &target_capacity);
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, target_limit, (const char *)source, -2, &target_capacity);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
{
int32_t source_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- char *target=0;
- source_limit=I18N_UPRV_LENGTHOF(source);
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ char *target = 0;
+ source_limit = I18N_UPRV_LENGTHOF(source);
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, -1, (const char*)source, source_limit, &target_capacity);
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", target, -1, (const char *)source, source_limit, &target_capacity);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
{
int32_t target_limit = 0, source_limit = 0, target_capacity = 0;
- const uint8_t source[]={ 0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
- source_limit=I18N_UPRV_LENGTHOF(source);
+ const uint8_t source[] = {0x00, 0x04, 0x05, 0x06, 0xa2, 0xb4, 0x00};
+ source_limit = I18N_UPRV_LENGTHOF(source);
target_limit = target_capacity + 1;
- ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char*)source, source_limit, &target_capacity);
+ ret = i18n_ucnv_convert("ibm-1364", "ibm-1363", NULL, target_limit, (const char *)source, source_limit, &target_capacity);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_p(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n1(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n2(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n3(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n4(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n5(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_from_algorithmic_n6(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100];
int utc_capi_base_utils_i18n_ucnv_to_algorithmic_p(void)
{
static const uint8_t
- utf8[]={
+ utf8[] = {
/* 4e00 30a1 ff61 0410 */
- 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90
- },
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ 0xe4, 0xb8, 0x80, 0xe3, 0x82, 0xa1, 0xef, 0xbd, 0xa1, 0xd0, 0x90},
+ shiftJIS[] = {0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100], shiftJIS_nul[100];
return 0;
}
-
/**
* @testcase utc_capi_base_utils_i18n_ucnv_to_algorithmic_n1
* @since_tizen 6.0
int utc_capi_base_utils_i18n_ucnv_to_algorithmic_n1(void)
{
static const uint8_t
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ shiftJIS[] = {
+ 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100], shiftJIS_nul[100];
int utc_capi_base_utils_i18n_ucnv_to_algorithmic_n2(void)
{
static const uint8_t
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ shiftJIS[] = {
+ 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100], shiftJIS_nul[100];
int utc_capi_base_utils_i18n_ucnv_to_algorithmic_n3(void)
{
static const uint8_t
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ shiftJIS[] = {
+ 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100], shiftJIS_nul[100];
int utc_capi_base_utils_i18n_ucnv_to_algorithmic_n5(void)
{
static const uint8_t
- shiftJIS[]={
- 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40
- };
+ shiftJIS[] = {
+ 0x88, 0xea, 0x83, 0x40, 0xa1, 0x84, 0x40};
int32_t length;
char target[100], shiftJIS_nul[100];
count = i18n_ucnv_count_available();
assert_neq(count, 0);
- for(int i = 0; i<count; ++i) {
+ for (int i = 0; i < count; ++i)
+ {
ret = i18n_ucnv_get_available_name(i, &result);
assert_eq(ret, I18N_ERROR_NONE);
}
{
const char *result;
- ret = i18n_ucnv_get_available_name(0xffff+1, &result);
+ ret = i18n_ucnv_get_available_name(0xffff + 1, &result);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
const char *alias;
uint16_t alias_num;
- for(alias_num = 0; alias_num < number; ++alias_num) {
+ for (alias_num = 0; alias_num < number; ++alias_num)
+ {
ret = i18n_ucnv_get_alias("utf-8", alias_num, &alias);
assert_eq(ret, I18N_ERROR_NONE);
assert_eq(strcmp(aliases[alias_num], alias), 0);
int utc_capi_base_utils_i18n_ucnv_get_standard_p(void)
{
uint16_t count = i18n_ucnv_count_standards();
- for(int i = 0; i < count -1; ++i) {
+ for (int i = 0; i < count - 1; ++i)
+ {
const char *standard;
ret = i18n_ucnv_get_standard(i, &standard);
assert_eq(ret, I18N_ERROR_NONE);
int utc_capi_base_utils_i18n_ucnv_get_standard_name_p(void)
{
const char *tag;
- ret =i18n_ucnv_get_standard_name("ascii", "IANA", &tag);
+ ret = i18n_ucnv_get_standard_name("ascii", "IANA", &tag);
assert_eq(ret, I18N_ERROR_NONE);
assert_eq(strcmp(tag, "ANSI_X3.4-1968"), 0);
int utc_capi_base_utils_i18n_ucnv_get_standard_name_n1(void)
{
const char *tag;
- ret =i18n_ucnv_get_standard_name(NULL, "IANA", &tag);
+ ret = i18n_ucnv_get_standard_name(NULL, "IANA", &tag);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
int utc_capi_base_utils_i18n_ucnv_get_standard_name_n2(void)
{
const char *tag;
- ret =i18n_ucnv_get_standard_name("ascii", NULL, &tag);
+ ret = i18n_ucnv_get_standard_name("ascii", NULL, &tag);
assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);
return 0;
}
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200], ascii_result[200];
int32_t len, ascii_len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
0x5c, 0x73, 0x68, 0x61, 0x72, 0x65,
0x5c, 0x64, 0x61, 0x74, 0x61,
0x5c, 0x69, 0x63, 0x75, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
- 0
- };
+ 0};
i18n_uchar result[200];
int32_t len;
*/
int utc_capi_base_utils_i18n_ucnv_detect_unicode_signature_p(void)
{
- static const char* data[] = {
- "\xFE\xFF\x00\x00", /* UTF-16BE */
- "\xFF\xFE\x00\x00", /* UTF-16LE */
- "\xEF\xBB\xBF\x00", /* UTF-8 */
- "\x0E\xFE\xFF\x00", /* SCSU */
+ static const char *data[] = {
+ "\xFE\xFF\x00\x00", /* UTF-16BE */
+ "\xFF\xFE\x00\x00", /* UTF-16LE */
+ "\xEF\xBB\xBF\x00", /* UTF-8 */
+ "\x0E\xFE\xFF\x00", /* SCSU */
- "\xFE\xFF", /* UTF-16BE */
- "\xFF\xFE", /* UTF-16LE */
- "\xEF\xBB\xBF", /* UTF-8 */
- "\x0E\xFE\xFF", /* SCSU */
+ "\xFE\xFF", /* UTF-16BE */
+ "\xFF\xFE", /* UTF-16LE */
+ "\xEF\xBB\xBF", /* UTF-8 */
+ "\x0E\xFE\xFF", /* SCSU */
- "\xFE\xFF\x41\x42", /* UTF-16BE */
- "\xFF\xFE\x41\x41", /* UTF-16LE */
- "\xEF\xBB\xBF\x41", /* UTF-8 */
- "\x0E\xFE\xFF\x41", /* SCSU */
+ "\xFE\xFF\x41\x42", /* UTF-16BE */
+ "\xFF\xFE\x41\x41", /* UTF-16LE */
+ "\xEF\xBB\xBF\x41", /* UTF-8 */
+ "\x0E\xFE\xFF\x41", /* SCSU */
"\x2B\x2F\x76\x38\x2D", /* UTF-7 */
"\x2B\x2F\x76\x38\x41", /* UTF-7 */
"\x2B\x2F\x76\x39\x41", /* UTF-7 */
"\x2B\x2F\x76\x2B\x41", /* UTF-7 */
- "\x2B\x2F\x76\x2F\x41", /* UTF-7 */
+ "\x2B\x2F\x76\x2F\x41", /* UTF-7 */
- "\xDD\x73\x66\x73" /* UTF-EBCDIC */
+ "\xDD\x73\x66\x73" /* UTF-EBCDIC */
};
- static const char* expected[] = {
+ static const char *expected[] = {
"UTF-16BE",
"UTF-16LE",
"UTF-8",
"UTF-7",
"UTF-7",
- "UTF-EBCDIC"
- };
+ "UTF-EBCDIC"};
- static const int32_t expected_len[] ={
+ static const int32_t expected_len[] = {
2, 2, 3, 3,
2, 2, 3, 3,
2, 2, 3, 3,
5, 4, 4, 4, 4,
- 4
- };
+ 4};
const char *source = NULL;
const char *name = NULL;
int32_t signature_length = -1;
- for(int i = 0; i<I18N_UPRV_LENGTHOF(data); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(data); ++i)
+ {
source = data[i];
ret = i18n_ucnv_detect_unicode_signature(source, -1, &signature_length, &name);
assert_eq(ret, I18N_ERROR_NONE);
*/
int utc_capi_base_utils_i18n_ucnv_from_ucount_pending_p(void)
{
- static const struct {
+ static const struct
+ {
i18n_uchar input[6];
int32_t len;
int32_t exp;
- }from_unicode_tests[] = {
- {{ 0xdbc4},1,1},
- {{ 0xdbc4, 0xde34, 0xd84d},3,1},
+ } from_unicode_tests[] = {
+ {{0xdbc4}, 1, 1},
+ {{0xdbc4, 0xde34, 0xd84d}, 3, 1},
};
ret = i18n_ucnv_create("UTF-8", &cnv);
assert_eq(ret, I18N_ERROR_NONE);
- for(int i = 0; i<I18N_UPRV_LENGTHOF(from_unicode_tests); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(from_unicode_tests); ++i)
+ {
char tgt[10];
char *target = tgt;
char *target_limit = target + 10;
*/
int utc_capi_base_utils_i18n_ucnv_to_ucount_pending_p(void)
{
- static const struct {
+ static const struct
+ {
char input[6];
int32_t len;
int32_t exp;
- }to_unicode_tests[] = {
- {{0x05, 0x01, 0x02},3,3},
- {{0x01, 0x02},2,2},
- {{0x07, 0x00, 0x01, 0x02},4,4},
+ } to_unicode_tests[] = {
+ {{0x05, 0x01, 0x02}, 3, 3},
+ {{0x01, 0x02}, 2, 2},
+ {{0x07, 0x00, 0x01, 0x02}, 4, 4},
};
ret = i18n_ucnv_create("UTF-8", &cnv);
assert_eq(ret, I18N_ERROR_NONE);
- for(int i = 0; i<I18N_UPRV_LENGTHOF(to_unicode_tests); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(to_unicode_tests); ++i)
+ {
i18n_uchar tgt[10];
i18n_uchar *target = tgt;
i18n_uchar *target_limit = target + 10;
const char *fixed_width[] = {
"US-ASCII",
"UTF32",
- "ibm-5478_P100-1995"
- };
+ "ibm-5478_P100-1995"};
const char *not_fixed_width[] = {
"GB18030",
"UTF8",
"windows-949-2000",
- "UTF16"
- };
+ "UTF16"};
- for(int i = 0; i<I18N_UPRV_LENGTHOF(fixed_width); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(fixed_width); ++i)
+ {
ret = i18n_ucnv_create(fixed_width[i], &cnv);
assert_eq(ret, I18N_ERROR_NONE);
assert_eq(result, true);
}
- for(int i = 0; i<I18N_UPRV_LENGTHOF(not_fixed_width); ++i) {
+ for (int i = 0; i < I18N_UPRV_LENGTHOF(not_fixed_width); ++i)
+ {
ret = i18n_ucnv_create(not_fixed_width[i], &cnv);
assert_eq(ret, I18N_ERROR_NONE);