cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=54bedbe1f14ffda6a8acdd2d180786bd8fc15318
commit 54bedbe1f14ffda6a8acdd2d180786bd8fc15318 Author: vivek <vivek.el...@samsung.com> Date: Mon Mar 23 19:29:55 2015 +0100 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.el...@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2218 Signed-off-by: Cedric BAIL <ced...@osg.samsung.com> --- src/tests/eina/eina_test_xattr.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/tests/eina/eina_test_xattr.c b/src/tests/eina/eina_test_xattr.c index d70e952..72c0c3d 100644 --- a/src/tests/eina/eina_test_xattr.c +++ b/src/tests/eina/eina_test_xattr.c @@ -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 --