forked from enlightenment/efl
eina: add test cases for various eina xattr data type functions
Summary: Added test cases for eina_xattr_string_set, eina_xattr_int_set and eina_xattr_double_set functions Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2218 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
2dc7ad52df
commit
54bedbe1f1
|
@ -223,6 +223,52 @@ START_TEST(eina_test_xattr_list)
|
|||
eina_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eina_test_xattr_types)
|
||||
{
|
||||
char *filename = "tmpfile";
|
||||
char *str_attr = "user.name", *ret_str;
|
||||
char *str_data = "Vivek Ellur";
|
||||
char *int_attr = "user.id";
|
||||
int int_data = 1234, int_ret;
|
||||
char *double_attr = "user.size";
|
||||
double double_data = 123.456, double_ret;
|
||||
int fd;
|
||||
Eina_Bool ret;
|
||||
Eina_Tmpstr *test_file_path;
|
||||
|
||||
eina_init();
|
||||
|
||||
test_file_path = get_file_path(XATTR_TEST_DIR, filename);
|
||||
fd = open(test_file_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
fail_if(fd == 0);
|
||||
|
||||
ret = eina_xattr_string_set(test_file_path, str_attr, str_data, EINA_XATTR_INSERT);
|
||||
fail_if(ret != EINA_TRUE);
|
||||
ret_str = eina_xattr_string_get(test_file_path, str_attr);
|
||||
fail_if(ret_str == NULL);
|
||||
fail_if(strcmp(ret_str, str_data) != 0);
|
||||
free(ret_str);
|
||||
|
||||
ret = eina_xattr_int_set(test_file_path, int_attr, int_data, EINA_XATTR_INSERT);
|
||||
fail_if(ret != EINA_TRUE);
|
||||
ret = eina_xattr_int_get(test_file_path, int_attr, &int_ret);
|
||||
fail_if(ret != EINA_TRUE);
|
||||
fail_if(int_data != int_ret);
|
||||
|
||||
ret = eina_xattr_double_set(test_file_path, double_attr, double_data, EINA_XATTR_INSERT);
|
||||
fail_if(ret != EINA_TRUE);
|
||||
ret = eina_xattr_double_get(test_file_path, double_attr, &double_ret);
|
||||
fail_if(ret != EINA_TRUE);
|
||||
fail_if(double_data != double_ret);
|
||||
|
||||
close(fd);
|
||||
unlink(test_file_path);
|
||||
eina_tmpstr_del(test_file_path);
|
||||
|
||||
eina_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -231,6 +277,7 @@ eina_test_xattr(TCase *tc)
|
|||
#ifdef XATTR_TEST_DIR
|
||||
tcase_add_test(tc, eina_test_xattr_set);
|
||||
tcase_add_test(tc, eina_test_xattr_list);
|
||||
tcase_add_test(tc, eina_test_xattr_types);
|
||||
#else
|
||||
(void)tc;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue