]> code.delx.au - pulseaudio/blobdiff - src/tests/strlist-test.c
tests: Minor alsa-time-test improvments
[pulseaudio] / src / tests / strlist-test.c
index 2bd1645c0436bca7c30358794b06ca5817ea744f..6a4f4bbf6b52aa72d3e5bf0f751e0a3fd67f9a51 100644 (file)
@@ -1,11 +1,16 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdio.h>
+#include <check.h>
 
 #include <pulse/xmalloc.h>
-#include <pulse/gccmacro.h>
 
 #include <pulsecore/strlist.h>
+#include <pulsecore/core-util.h>
 
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char* argv[]) {
+START_TEST (strlist_test) {
     char *t, *u;
     pa_strlist *l = NULL;
 
@@ -19,25 +24,47 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED 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);
+}
+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 0;
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }