tests: Build core/playlists/artist test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c67d09740c
commit
487274ff00
|
@ -8,6 +8,7 @@
|
|||
#ifndef OCARINA_CORE_PLAYLIST_H
|
||||
#define OCARINA_CORE_PLAYLIST_H
|
||||
|
||||
#include <core/playlists/artist.h>
|
||||
#include <core/playlists/system.h>
|
||||
#include <core/queue.h>
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@ function(playlist_unit_test name)
|
|||
endfunction()
|
||||
|
||||
playlist_unit_test(System)
|
||||
playlist_unit_test(Artist)
|
||||
|
|
|
@ -12,7 +12,7 @@ def PlaylistTest(name):
|
|||
|
||||
core_objs += [ env.Object("../../../core/playlists/generic.c") ]
|
||||
core_objs += [ env.Object("../../../core/playlists/system.c") ]
|
||||
res += [ PlaylistTest("artist") ]
|
||||
core_objs += [ env.Object("../../../core/playlists/artist.c") ]
|
||||
res += [ PlaylistTest("library") ]
|
||||
|
||||
Return("res")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright 2016 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/idle.h>
|
||||
#include <core/playlists/artist.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/library.h>
|
||||
#include <core/tags/tags.h>
|
||||
|
@ -11,43 +11,47 @@
|
|||
|
||||
void test_artist()
|
||||
{
|
||||
struct playlist *playlist;
|
||||
struct library *library;
|
||||
struct artist *artist;
|
||||
struct artist *artist;
|
||||
|
||||
g_assert_false(playlist_new(PL_ARTIST, "Koji Kondo"));
|
||||
g_assert_null(playlist_get_queue(PL_ARTIST, "Koji Kondo"));
|
||||
|
||||
artist = artist_find("Koji Kondo");
|
||||
g_assert_null(artist->ar_playlist);
|
||||
g_assert_false(playlist_add(PL_ARTIST, "Koji Kondo", track_get(0)));
|
||||
|
||||
pl_artist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
|
||||
g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 2);
|
||||
g_assert_nonnull(artist->ar_playlist);
|
||||
g_assert_false(playlist_remove(PL_ARTIST, "Koji Kondo", track_get(0)));
|
||||
g_assert_cmpuint(playlist_size(PL_ARTIST, "Koji Kondo"), ==, 2);
|
||||
|
||||
g_assert_false(playlist_delete(PL_ARTIST, "Koji Kondo"));
|
||||
pl_artist_deinit();
|
||||
g_assert_null(artist->ar_playlist);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct library *library;
|
||||
int ret;
|
||||
|
||||
idle_init_sync();
|
||||
tags_init();
|
||||
while (idle_run_task()) {};
|
||||
|
||||
test_equal(pl_artist.pl_new("Koji Kondo"), (bool)false);
|
||||
test_equal((void *)pl_artist.pl_get_queue("Koji Kondo"), NULL);
|
||||
|
||||
/* Add tracks to the collection. */
|
||||
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");
|
||||
|
||||
artist = artist_find("Koji Kondo");
|
||||
test_equal(artist->ar_playlist, NULL);
|
||||
test_equal(pl_artist.pl_delete("Koji Kondo"), (bool)false);
|
||||
test_equal(pl_artist.pl_add_track("Koji Kondo", track_get(0)), (bool)false);
|
||||
|
||||
pl_artist_init(NULL);
|
||||
while (idle_run_task()) {};
|
||||
playlist = (struct playlist *)artist->ar_playlist;
|
||||
|
||||
test_equal(queue_size(pl_artist.pl_get_queue("Koji Kondo")), 2);
|
||||
test_not_equal(artist->ar_playlist, NULL);
|
||||
test_equal(queue_size(&playlist->pl_queue), 2);
|
||||
test_equal(pl_artist.pl_remove_track("Koji Kondo", track_get(0)), (bool)false);
|
||||
|
||||
pl_artist_deinit();
|
||||
test_equal(artist->ar_playlist, NULL);
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
g_test_add_func("/Core/Playlists/Artist", test_artist);
|
||||
ret = g_test_run();
|
||||
|
||||
tags_deinit();
|
||||
idle_deinit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Artist Playlists", test_artist),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue