Add test for gbuf
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#include <check.h>
|
||||
#include <string.h>
|
||||
#include <ucore/ucore_buffer.h>
|
||||
|
||||
|
||||
START_TEST (test_new_gbuf)
|
||||
GBuf *buf = uc_new_gbuf(11);
|
||||
|
||||
fail_if(buf == NULL);
|
||||
fail_if(buf->len != 11);
|
||||
fail_if(buf->ref_cnt != 1);
|
||||
fail_if(buf->buf == NULL);
|
||||
fail_if(buf->used != 0);
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_gbuf_append1)
|
||||
const char *data = "lorum_ ipson 1234567890";
|
||||
int rc;
|
||||
GBuf *buf = uc_new_gbuf(11);
|
||||
|
||||
fail_if(buf == NULL);
|
||||
|
||||
rc = uc_gbuf_append(buf, data, strlen(data) + 1);
|
||||
fail_if(rc != 0);
|
||||
fail_if(buf->used != strlen(data) + 1);
|
||||
fail_if(strcmp(data, buf->buf) != 0);
|
||||
|
||||
END_TEST
|
||||
|
||||
|
||||
Suite *buffer_suite(void)
|
||||
{
|
||||
Suite *s = suite_create("buffer");
|
||||
TCase *tc = tcase_create("buffer (GBuf) tests");
|
||||
tcase_add_test(tc, test_new_gbuf);
|
||||
tcase_add_test(tc, test_gbuf_append1);
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user