1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

More playlist tests

This commit is contained in:
Moritz Grimm 2015-05-30 21:52:42 +02:00
parent 8d9f475e38
commit 542a21b7ab
7 changed files with 60 additions and 1 deletions

View File

@ -54,6 +54,10 @@ EXTRA_DIST = \
config-bad2.xml \
config-bad3.xml \
config-bad4.xml \
play-bad.sh \
play-bad2.sh \
play-bad3.sh \
playlist-bad.txt \
playlist.txt
CLEANFILES = *~ *.core core *.gcno *.gcda

View File

@ -28,8 +28,18 @@ START_TEST(test_playlist_file)
ck_assert_ptr_eq(playlist_get_next(p), NULL);
ck_assert_int_eq(playlist_reread(&p), 1);
ck_assert_str_eq(playlist_get_next(p), "1.ogg");
ck_assert_str_eq(playlist_get_next(p), "2.ogg");
ck_assert_str_eq(playlist_get_next(p), "3.ogg");
ck_assert_str_eq(playlist_get_next(p), "4.ogg");
ck_assert_str_eq(playlist_get_next(p), "5.ogg");
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_shuffle(p);
playlist_free(&p);
p = playlist_read(SRCDIR "/playlist-bad.txt");
ck_assert_ptr_ne(p, NULL);
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_free(&p);
}
END_TEST
@ -39,6 +49,12 @@ START_TEST(test_playlist_program)
ck_assert_ptr_eq(playlist_program("nonexistent.sh"), NULL);
ck_assert_ptr_eq(playlist_program(SRCDIR "/playlist.txt"), NULL);
p = playlist_program(SRCDIR "/bad-executable.sh");
ck_assert_ptr_ne(p, NULL);
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_free(&p);
p = playlist_program(EXAMPLESDIR "/play.sh");
ck_assert_ptr_ne(p, NULL);
ck_assert_str_eq(playlist_get_next(p),
@ -48,11 +64,37 @@ START_TEST(test_playlist_program)
ck_assert_int_eq(playlist_goto_entry(p,
"Great_Artist_-_Great_Song.ogg"), 0);
ck_assert_int_eq(playlist_reread(&p), 0);
playlist_rewind(p);
playlist_shuffle(p);
playlist_free(&p);
p = playlist_program(SRCDIR "/bad-executable.sh");
p = playlist_program(SRCDIR "/play-bad.sh");
ck_assert_ptr_ne(p, NULL);
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_free(&p);
p = playlist_program(SRCDIR "/play-bad2.sh");
ck_assert_ptr_ne(p, NULL);
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_free(&p);
p = playlist_program(SRCDIR "/play-bad3.sh");
ck_assert_ptr_ne(p, NULL);
ck_assert_ptr_eq(playlist_get_next(p), NULL);
playlist_free(&p);
}
END_TEST
START_TEST(test_playlist_free)
{
playlist_t p;
p = playlist_read(SRCDIR "/playlist.txt");
ck_assert_ptr_ne(p, NULL);
playlist_free(&p);
ck_assert_ptr_eq(p, NULL);
playlist_free(&p);
playlist_free(NULL);
}
END_TEST
@ -68,6 +110,7 @@ playlist_suite(void)
tcase_add_checked_fixture(tc_playlist, setup_checked, teardown_checked);
tcase_add_test(tc_playlist, test_playlist_file);
tcase_add_test(tc_playlist, test_playlist_program);
tcase_add_test(tc_playlist, test_playlist_free);
suite_add_tcase(s, tc_playlist);
return (s);

3
tests/play-bad.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "$(cat playlist-bad.txt)"

3
tests/play-bad2.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo ""

3
tests/play-bad3.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
exit 0

1
tests/playlist-bad.txt Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,7 @@
1.ogg
2.ogg
# This is a comment
3.ogg
4.ogg
5.ogg