ocarina/tests/core/playlist.c

63 lines
1.7 KiB
C

/*
* Copyright 2016 (c) Anna Schumaker.
*/
#include <core/idle.h>
#include <core/playlist.h>
#include <core/settings.h>
#include <core/tags/tags.h>
static void test_null()
{
g_assert_null(playlist_new(PL_MAX_TYPE, "NULL"));
g_assert_null(playlist_new(PL_MAX_TYPE, NULL));
g_assert_false(playlist_delete(NULL));
g_assert_null(playlist_lookup(PL_MAX_TYPE, "NULL"));
g_assert_null(playlist_lookup(PL_MAX_TYPE, NULL));
g_assert_null(playlist_get(PL_MAX_TYPE, 0));
g_assert(playlist_current() == playlist_lookup(PL_SYSTEM, "Collection"));
g_assert_false(playlist_select(NULL));
g_assert(playlist_current() == playlist_lookup(PL_SYSTEM, "Collection"));
g_assert_false(playlist_add(NULL, NULL));
g_assert_false(playlist_add(NULL, track_get(0)));
g_assert_false(playlist_has(NULL, NULL));
g_assert_false(playlist_has(NULL, track_get(0)));
g_assert_cmpuint(playlist_size(NULL), ==, 0);
g_assert_false(playlist_remove(NULL, NULL));
g_assert_false(playlist_remove(NULL, track_get(0)));
g_assert_false(playlist_get_random(NULL));
playlist_set_random(NULL, true);
g_assert_false(playlist_get_random(NULL));
g_assert_false(playlist_sort(NULL, COMPARE_TRACK, true));
g_assert_false(playlist_sort(NULL, COMPARE_TRACK, false));
}
int main(int argc, char **argv)
{
struct library *library;
int ret;
idle_init_sync();
settings_init();
tags_init();
playlist_init(NULL, NULL);
while (idle_run_task()) {};
library = library_find("tests/Music");
track_add(library, "tests/Music/Hyrule Symphony/01 - Title Theme.ogg");
g_test_init(&argc, &argv, NULL);
g_test_add_func("/Core/Playlist/NULL", test_null);
ret = g_test_run();
playlist_deinit();
tags_deinit();
settings_deinit();
idle_deinit();
return ret;
}