core/containers/queue: Add _q_size() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
79627bb287
commit
bf332b36a5
|
@ -21,4 +21,10 @@ static inline void _q_init(struct _queue *queue)
|
|||
g_queue_init(&queue->_queue);
|
||||
}
|
||||
|
||||
/* Called to find the size of a queue. */
|
||||
static inline guint _q_size(struct _queue *queue)
|
||||
{
|
||||
return g_queue_get_length(&queue->_queue);
|
||||
}
|
||||
|
||||
#endif /* OCARINA_CORE_CONTAINERS_QUEUE_H */
|
||||
|
|
|
@ -4,17 +4,18 @@
|
|||
#include <core/containers/queue.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_init()
|
||||
static void test_stress(unsigned int N)
|
||||
{
|
||||
struct _queue queue = _Q_INIT();
|
||||
|
||||
/* _q_init() */
|
||||
test_equal((void *)queue._queue.head, NULL);
|
||||
test_equal((void *)queue._queue.tail, NULL);
|
||||
test_equal(queue._queue.length, 0);
|
||||
|
||||
test_equal(_q_size(&queue), 0);
|
||||
}
|
||||
|
||||
static void test_basics() { test_stress(10); }
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Queue Initialization", test_init),
|
||||
UNIT_TEST("Queue Basics", test_basics),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue