51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <gui/queue.h>
|
|
#include <tests/test.h>
|
|
|
|
static void *test_queue_init(struct queue *queue)
|
|
{
|
|
return gui_queue_alloc(queue, "Test Queue",
|
|
GQ_CAN_RANDOM | GQ_CAN_REPEAT);
|
|
}
|
|
|
|
void __test_queue_clear(struct queue *queue, unsigned int n) {}
|
|
|
|
static const struct queue_ops test_ops = {
|
|
.qop_init = test_queue_init,
|
|
.qop_deinit = gui_queue_free,
|
|
.qop_cleared = __test_queue_clear,
|
|
};
|
|
|
|
static void test_queue()
|
|
{
|
|
struct gui_queue *gq;
|
|
struct queue q;
|
|
|
|
test_equal(gui_queue_can_random(NULL), (bool)false);
|
|
test_equal(gui_queue_can_repeat(NULL), (bool)false);
|
|
|
|
queue_init(&q, 0, &test_ops);
|
|
gq = gui_queue(&q);
|
|
|
|
test_not_equal((void *)gq, NULL);
|
|
test_equal((void *)gq->gq_queue, (void *)&q);
|
|
test_equal(gq->gq_text, "Test Queue");
|
|
|
|
test_equal(gq->gq_flags, GQ_CAN_RANDOM | GQ_CAN_REPEAT);
|
|
test_equal(gui_queue_can_random(gq), (bool)true);
|
|
test_equal(gui_queue_can_repeat(gq), (bool)true);
|
|
|
|
gq->gq_flags = 0;
|
|
test_equal(gui_queue_can_random(gq), (bool)false);
|
|
test_equal(gui_queue_can_repeat(gq), (bool)false);
|
|
|
|
queue_deinit(&q);
|
|
test_equal((void *)gui_queue(&q), NULL);
|
|
}
|
|
|
|
DECLARE_UNIT_TESTS(
|
|
UNIT_TEST("Queue", test_queue),
|
|
);
|