From 0aed0a0fadb607a04c3f9cb15e4cb49262c115d9 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 28 Aug 2013 21:16:47 +0200 Subject: [PATCH] t/libsysdb_test: Use a list of test-suite creators. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … rather than adding a new block for each new test-suite. --- t/libsysdb_test.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/t/libsysdb_test.c b/t/libsysdb_test.c index 79ba421..2351f19 100644 --- a/t/libsysdb_test.c +++ b/t/libsysdb_test.c @@ -29,27 +29,29 @@ #include "libsysdb_test.h" +typedef Suite *(*suite_creator)(void); + 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 */ -- 2.30.2