Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
archived/test/t_queue.c
Henrik Hautakoski 4a2665004e queue.c: remove queue_clear.
client code knows what objects is stored in the queue
and its only 3 lines to do a simple free() on the items.
2010-11-10 08:45:44 +01:00

37 lines
624 B
C

#include <assert.h>
#include <stdio.h>
#include "../src/queue.h"
int main() {
int i, map[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
queue_t q = queue_init();
for(i=0; i < 10; i++)
queue_enqueue(q, &map[i]);
assert(queue_num_items(q) == 10);
for(i=0; i < 4; i++) {
int *c = queue_dequeue(q);
if (c == NULL)
continue;
assert(c == &map[i]);
}
for(i=4; i < 10; i++)
queue_enqueue(q, &map[i]);
assert(queue_isempty(q) == 0);
while(queue_dequeue(q));
assert(queue_isempty(q));
queue_destroy(q);
return 0;
}