From fa1f23617742be5a3b38103f92359782858d91ab Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Mon, 22 Sep 2025 14:16:38 -0400 Subject: [PATCH] Add macro to reduce boilerplate code --- src/clue-matches-tests.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index e7dd49e0..18fb7c8c 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -25,9 +25,13 @@ #include "word-list-test-utils.h" #include "test-utils.h" -#define EGG_IPUZ "tests/clue-matches/egg.ipuz" -#define VALID_INTERSECTION_IPUZ "tests/clue-matches/valid-intersection.ipuz" -#define INVALID_INTERSECTION_IPUZ "tests/clue-matches/invalid-intersection.ipuz" +#define ADD_IPUZ_TEST(test_name, file_name) \ + g_test_add ("/clue_matches/" #test_name, \ + Fixture, \ + "tests/clue-matches/" #file_name, \ + fixture_set_up, \ + test_name, \ + fixture_tear_down) typedef struct { WordList *word_list; @@ -151,23 +155,8 @@ int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); - g_test_add ("/clue_matches/test_egg_ipuz", - Fixture, - EGG_IPUZ, - fixture_set_up, - test_egg_ipuz, - fixture_tear_down); - g_test_add ("/clue_matches/valid_intersection_ipuz", - Fixture, - VALID_INTERSECTION_IPUZ, - fixture_set_up, - test_valid_intersection_ipuz, - fixture_tear_down); - g_test_add ("/clue_matches/invalid_intersection_ipuz", - Fixture, - INVALID_INTERSECTION_IPUZ, - fixture_set_up, - test_invalid_intersection_ipuz, - fixture_tear_down); + ADD_IPUZ_TEST (test_egg_ipuz, egg.ipuz); + ADD_IPUZ_TEST (test_valid_intersection_ipuz, valid-intersection.ipuz); + ADD_IPUZ_TEST (test_invalid_intersection_ipuz, invalid-intersection.ipuz); return g_test_run (); } -- GitLab