Code

t/libsysdb_test: Use a list of test-suite creators.
authorSebastian Harl <sh@tokkee.org>
Wed, 28 Aug 2013 19:16:47 +0000 (21:16 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 28 Aug 2013 19:16:47 +0000 (21:16 +0200)
… rather than adding a new block for each new test-suite.

t/libsysdb_test.c

index 79ba4218d284e1a7fde38e54125c8302ed287206..2351f19a600687b6aea0ed632d9b0fd55969c939 100644 (file)
 
 #include "libsysdb_test.h"
 
 
 #include "libsysdb_test.h"
 
+typedef Suite *(*suite_creator)(void);
+
 int
 main(void)
 {
        int failed = 0;
 int
 main(void)
 {
        int failed = 0;
-
-       SRunner *sr;
-       Suite *s;
-
-       /* t/utils/llist_test */
-       s = util_llist_suite();
-       sr = srunner_create(s);
-       srunner_run_all(sr, CK_NORMAL);
-       failed += srunner_ntests_failed(sr);
-       srunner_free(sr);
-
-       /* t/utils/dbi_test */
-       s = util_dbi_suite();
-       sr = srunner_create(s);
-       srunner_run_all(sr, CK_NORMAL);
-       failed += srunner_ntests_failed(sr);
-       srunner_free(sr);
+       size_t i;
+
+       suite_creator creators[] = {
+               util_llist_suite,
+               util_dbi_suite,
+       };
+
+       for (i = 0; i < SDB_STATIC_ARRAY_LEN(creators); ++i) {
+               SRunner *sr;
+               Suite *s;
+
+               s = creators[i]();
+               sr = srunner_create(s);
+               srunner_run_all(sr, CK_NORMAL);
+               failed += srunner_ntests_failed(sr);
+               srunner_free(sr);
+       }
 
        return failed;
 } /* main */
 
        return failed;
 } /* main */