ocarina/tests/core/queue.c

75 lines
2.0 KiB
C

/*
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/idle.h>
#include <core/queue.h>
#include <core/tags/tags.h>
#include <tests/test.h>
unsigned int count_init = 0;
static void *queue_op_init(struct queue *queue, void *data)
{
count_init++;
return GUINT_TO_POINTER(count_init);
}
static const struct queue_ops test_ops = {
.qop_init = queue_op_init,
};
static void test_init()
{
struct queue q;
queue_init(&q, NULL, NULL);
g_assert_cmpuint(count_init, ==, 0);
g_assert_null(q.q_private);
g_assert_null(q.q_ops);
queue_init(&q, &test_ops, NULL);
g_assert_cmpuint(count_init, ==, 1);
g_assert_cmpuint(GPOINTER_TO_UINT(q.q_private), ==, 1);
g_assert(q.q_ops == &test_ops);
}
int main(int argc, char **argv)
{
struct library *library;
int ret;
idle_init_sync();
tags_init();
while (idle_run_task()) {}
library = library_find("tests/Music");
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
track_add(library, "tests/Music/Hyrule Symphony/02 - Kokiri Forest.ogg");
track_add(library, "tests/Music/Hyrule Symphony/03 - Hyrule Field.ogg");
track_add(library, "tests/Music/Hyrule Symphony/04 - Hyrule Castle.ogg");
track_add(library, "tests/Music/Hyrule Symphony/05 - Lon Lon Ranch.ogg");
track_add(library, "tests/Music/Hyrule Symphony/06 - Kakariko Village.ogg");
track_add(library, "tests/Music/Hyrule Symphony/07 - Death Mountain.ogg");
track_add(library, "tests/Music/Hyrule Symphony/08 - Zora's Domain.ogg");
track_add(library, "tests/Music/Hyrule Symphony/09 - Gerudo Valley.ogg");
track_add(library, "tests/Music/Hyrule Symphony/10 - Ganondorf.ogg");
track_add(library, "tests/Music/Hyrule Symphony/11 - Princess Zelda.ogg");
track_add(library, "tests/Music/Hyrule Symphony/12 - Ocarina Medley.ogg");
track_add(library,
"tests/Music/Hyrule Symphony/13 - The Legend of Zelda Medley.ogg");
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Core/Queue/Initialization", test_init);
ret = g_test_run();
tags_deinit();
idle_deinit();
return ret;
}