tests/core: Update playlist test to the new framework
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b81b1eeda7
commit
1cb7eff37d
|
@ -27,9 +27,9 @@ res += [ CoreTest("queue", "queue.cpp") ]
|
|||
|
||||
env.UsePackage("taglib")
|
||||
res += [ CoreTest("library", "library.cpp") ]
|
||||
res += [ CoreTest("playlist", "playlist.cpp") ]
|
||||
|
||||
Return("res")
|
||||
|
||||
#test( "playlist" )
|
||||
#test( "deck" )
|
||||
#test( "audio" )
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <core/library.h>
|
||||
#include <core/playlist.h>
|
||||
#include <core/tags/tags.h>
|
||||
#include <tests/test.h>
|
||||
#include "test.h"
|
||||
|
||||
static IndexEntry *IDX_NULL = NULL;
|
||||
static Queue *Q_NULL = NULL;
|
||||
|
@ -22,7 +22,7 @@ static void test_init()
|
|||
/* init should work even if playlist.db doesn't exist! */
|
||||
playlist :: init();
|
||||
|
||||
test :: cp_data_dir();
|
||||
test_cp_data_dir();
|
||||
tags :: init();
|
||||
library :: init();
|
||||
playlist :: init();
|
||||
|
@ -102,38 +102,27 @@ static void test_delete()
|
|||
}
|
||||
|
||||
|
||||
static unsigned int _test_has_loop_banned(unsigned int i)
|
||||
{
|
||||
Track *track = tags :: get_track(i);
|
||||
bool has = playlist :: has(track, "Banned");
|
||||
if (i <= 3)
|
||||
return has ? LOOP_PASSED : LOOP_FAILED;
|
||||
return has ? LOOP_FAILED : LOOP_PASSED;
|
||||
}
|
||||
|
||||
static unsigned int _test_has_loop_favorites(unsigned int i)
|
||||
{
|
||||
Track *track = tags :: get_track(i);
|
||||
bool has = playlist :: has(track, "Favorites");
|
||||
if (i >= 16)
|
||||
return has ? LOOP_PASSED : LOOP_FAILED;
|
||||
return has ? LOOP_FAILED : LOOP_PASSED;
|
||||
}
|
||||
|
||||
static void test_has()
|
||||
{
|
||||
test_for_each(0, 24, 1, _test_has_loop_banned);
|
||||
test_for_each(0, 24, 1, _test_has_loop_favorites);
|
||||
Track *track;
|
||||
|
||||
for (unsigned int i = 0; i < 24; i++) {
|
||||
track = tags :: get_track(i);
|
||||
test_loop_equal(playlist :: has(track, "Banned"),
|
||||
(i <= 3) ? true : false, i);
|
||||
} test_loop_passed();
|
||||
|
||||
for (unsigned int i = 0; i < 24; i++) {
|
||||
track = tags :: get_track(i);
|
||||
test_loop_equal(playlist :: has(track, "Favorites"),
|
||||
(i >= 16) ? true : false, i);
|
||||
} test_loop_passed();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test :: rm_data_dir();
|
||||
|
||||
test :: run("Playlist Initialization Test", test_init);
|
||||
test :: run("Playlist Queue Test", test_queue);
|
||||
test :: run("Playlist Add Test", test_add);
|
||||
test :: run("Playlist Delete Test", test_delete);
|
||||
test :: run("Playlist Has Test", test_has);
|
||||
return 0;
|
||||
}
|
||||
DECLARE_UNIT_TESTS(
|
||||
UNIT_TEST("Playlist Init", test_init),
|
||||
UNIT_TEST("Playlist Queue", test_queue),
|
||||
UNIT_TEST("Playlist Add", test_add),
|
||||
UNIT_TEST("Playlist Delete", test_delete),
|
||||
UNIT_TEST("Playlist Has", test_has),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue