forked from enlightenment/efl
eina: add test case for eina_memdup in eina str
Summary: Added test case for eina_memdup function in eina_str test module Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2026 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
244707a3a7
commit
053430739e
|
@ -309,6 +309,36 @@ START_TEST(str_join_len)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(str_memdup)
|
||||
{
|
||||
struct temp {
|
||||
int i;
|
||||
char *s;
|
||||
double d;
|
||||
} t1,*t2;
|
||||
unsigned char buf[7], *temp_buf;
|
||||
|
||||
eina_init();
|
||||
|
||||
t1.i = 1234;
|
||||
t1.s = "hello";
|
||||
t1.d = 123.456;
|
||||
|
||||
t2 = (struct temp *)eina_memdup((unsigned char *)&t1, sizeof(struct temp), EINA_TRUE);
|
||||
fail_if(t2->i != t1.i);
|
||||
fail_if(strcmp(t2->s,t1.s) != 0);
|
||||
fail_if(t2->d != t1.d);
|
||||
free(t2);
|
||||
|
||||
memcpy(buf, "aaabbb", 6);
|
||||
temp_buf = eina_memdup(buf, 6, EINA_TRUE);
|
||||
fail_if(strcmp(temp_buf, "aaabbb") != 0);
|
||||
free(temp_buf);
|
||||
|
||||
eina_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
START_TEST(str_convert)
|
||||
{
|
||||
|
@ -346,6 +376,7 @@ eina_test_str(TCase *tc)
|
|||
tcase_add_test(tc, str_split);
|
||||
tcase_add_test(tc, str_lcat_lcpy);
|
||||
tcase_add_test(tc, str_join_len);
|
||||
tcase_add_test(tc, str_memdup);
|
||||
#ifdef HAVE_ICONV
|
||||
tcase_add_test(tc, str_convert);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue