Add test for uc_mbuf-copy_data

This commit is contained in:
Nils O. Selåsdal
2013-07-02 21:22:38 +02:00
parent bc65b3c421
commit 65c32810cb
3 changed files with 47 additions and 5 deletions
+25
View File
@@ -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);