测试用例:
///////////////////////////////////////////// test ////////////////////////////////////
#define TEST_BUF_SIZE 100
char test_buf[TEST_BUF_SIZE];
robin_queue_t test_queue = {
.buf = test_buf,
.buf_size = TEST_BUF_SIZE
};
void _test_queue(void)
{
int i,ret;
char *item = NULL;
queue_init(&test_queue);
for(i = 1;i <= test_queue.buf_size + 10;i ++) {
ret = queue_insert(&test_queue,(char)i);
if(ret != QUE_OK) {
printf("erro:%d ",i);
}
}
printf("====len:%d\n",queue_length(&test_queue));
while(!queue_is_empty(&test_queue)) {
item = queue_get_item(&test_queue);
if(item != NULL) {
printf("item:%d ",*item);
}
}
printf("\n\n");
int it = 0;//test_queue.buf_size/2;
while(!queue_is_full(&test_queue)) {
printf("inst:%d ",it);
queue_insert(&test_queue,(char)it);
it ++;
}
printf("\n\n");
while(!queue_is_empty(&test_queue)) {
item = queue_get_item(&test_queue);
if(item != NULL) {
printf("item:%d ",*item);
}
}
printf("\n\n");
printf("====len:%d\n",queue_length(&test_queue));
}
int main(void)
{
_test_queue();
return 0;
}
|