Add test for uc_mbuf-copy_data
This commit is contained in:
@@ -174,6 +174,30 @@ START_TEST (test_mbuf_pull_fail)
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_mbuf_copy)
|
||||
struct MBuf *mbuf;
|
||||
uint8_t *data1;
|
||||
struct MBuf *copy;
|
||||
|
||||
mbuf = uc_mbuf_new_inline_hr(10,5);
|
||||
fail_if(mbuf == NULL);
|
||||
|
||||
data1 = uc_mbuf_put(mbuf, 10);
|
||||
fail_if(data1 == NULL);
|
||||
|
||||
strcpy((char*)data1, "123456789");
|
||||
|
||||
copy = uc_mbuf_copy_data(mbuf);
|
||||
fail_if(copy == NULL);
|
||||
fail_if(uc_mbuf_len(copy) != 10);
|
||||
fail_if(uc_mbuf_headroom(copy) != 5);
|
||||
fail_if(memcmp(mbuf->head, copy->head, 10) != 0);
|
||||
|
||||
uc_mbuf_free(mbuf);
|
||||
uc_mbuf_free(copy);
|
||||
|
||||
END_TEST
|
||||
|
||||
|
||||
|
||||
Suite *mbuf_suite(void)
|
||||
@@ -189,6 +213,7 @@ Suite *mbuf_suite(void)
|
||||
tcase_add_test(tc, test_mbuf_push_fail);
|
||||
tcase_add_test(tc, test_mbuf_pull);
|
||||
tcase_add_test(tc, test_mbuf_pull_fail);
|
||||
tcase_add_test(tc, test_mbuf_copy);
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user