tests: modify strlist-test to use new 'check' framework

This commit is contained in:
Deng Zhengrong 2012-07-17 14:45:55 +08:00 committed by Arun Raghavan
parent 27f6065a3c
commit c2f7987f09
2 changed files with 33 additions and 5 deletions

View file

@ -405,9 +405,9 @@ extended_test_CFLAGS = $(AM_CFLAGS)
extended_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
strlist_test_SOURCES = tests/strlist-test.c
strlist_test_CFLAGS = $(AM_CFLAGS)
strlist_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
strlist_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
strlist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
strlist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
close_test_SOURCES = tests/close-test.c
close_test_CFLAGS = $(AM_CFLAGS)

View file

@ -1,10 +1,16 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <check.h>
#include <pulse/xmalloc.h>
#include <pulsecore/strlist.h>
#include <pulsecore/core-util.h>
int main(int argc, char* argv[]) {
START_TEST (strlist_test) {
char *t, *u;
pa_strlist *l = NULL;
@ -18,25 +24,47 @@ int main(int argc, char* argv[]) {
pa_strlist_free(l);
fprintf(stderr, "1: %s\n", t);
fail_unless(pa_streq(t, "a b c d e"));
l = pa_strlist_parse(t);
pa_xfree(t);
t = pa_strlist_tostring(l);
fprintf(stderr, "2: %s\n", t);
fail_unless(pa_streq(t, "a b c d e"));
pa_xfree(t);
l = pa_strlist_pop(l, &u);
fprintf(stderr, "3: %s\n", u);
fail_unless(pa_streq(u, "a"));
pa_xfree(u);
l = pa_strlist_remove(l, "c");
t = pa_strlist_tostring(l);
fprintf(stderr, "4: %s\n", t);
fail_unless(pa_streq(t, "b d e"));
pa_xfree(t);
pa_strlist_free(l);
return 0;
}
END_TEST
int main(int argc, char *argv[]) {
int failed = 0;
Suite *s;
TCase *tc;
SRunner *sr;
s = suite_create("StrList");
tc = tcase_create("strlist");
tcase_add_test(tc, strlist_test);
suite_add_tcase(s, tc);
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
failed = srunner_ntests_failed(sr);
srunner_free(sr);
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}