From 76cb300b0f1de6d91b3bd7ec7192ab6e3a8cfdcd Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 08:35:11 -0400 Subject: [PATCH 01/16] Use shorter macros --- src/clue-matches-tests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 4ac58731..7a20f23e 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -27,9 +27,9 @@ // #define _TEST_FILE "tests/clue-matches/.ipuz" -#define EGG_IPUZ_FILE_PATH "tests/clue-matches/egg.ipuz" -#define VALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/valid-intersection.ipuz" -#define INVALID_INTERSECTION_IPUZ_FILE_PATH "tests/clue-matches/invalid-intersection.ipuz" +#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" static IpuzGrid* create_grid (const gchar* filename) @@ -58,7 +58,7 @@ test_egg_ipuz (void) g_autoptr (WordArray) clue_matches = NULL; word_list = get_broda_word_list (); - grid = create_grid (EGG_IPUZ_FILE_PATH); + grid = create_grid (EGG_IPUZ); clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 2); clue_matches = word_list_find_clue_matches (word_list, clue, grid); @@ -88,7 +88,7 @@ test_valid_intersection_ipuz (void) g_autoptr (WordArray) clue_matches = NULL; word_list = get_broda_word_list (); - grid = create_grid (VALID_INTERSECTION_IPUZ_FILE_PATH); + grid = create_grid (VALID_INTERSECTION_IPUZ); clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 1); clue_matches = word_list_find_clue_matches (word_list, clue, grid); @@ -127,7 +127,7 @@ test_invalid_intersection_ipuz (void) g_autoptr (WordArray) clue_matches = NULL; word_list = get_broda_word_list (); - grid = create_grid (INVALID_INTERSECTION_IPUZ_FILE_PATH); + grid = create_grid (INVALID_INTERSECTION_IPUZ); clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 3); clue_matches = word_list_find_clue_matches (word_list, clue, grid); g_assert_cmpint (word_array_len (clue_matches), ==, 0); -- GitLab From 3ebb3e05d5ef27200d1c6a572ef4fdd24f9235da Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 09:08:00 -0400 Subject: [PATCH 02/16] Add str_array_to_word_array() --- src/clue-matches-tests.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 7a20f23e..42e99a82 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -49,6 +49,22 @@ get_clue (IpuzGrid* grid, IpuzClueDirection direction, guint index) return ipuz_clues_get_clue_by_id (IPUZ_CLUES (grid), &clue_id); } +static WordArray* +str_array_to_word_array (const gchar *str_array[], WordList *word_list) +{ + WordArray *word_array = word_array_new (); + for (guint i = 0; str_array[i] != NULL; i++) + { + WordIndex word_index; + gboolean success = word_list_lookup_index (word_list, + str_array[i], + &word_index); + g_assert (success); + word_array_add (word_array, word_index); + } + return word_array; +} + static void test_egg_ipuz (void) { -- GitLab From 1e1f5e67e916552f39b9b082912930b66040721e Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 11:50:20 -0400 Subject: [PATCH 03/16] Add test_clue_matches() --- src/clue-matches-tests.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 42e99a82..35bf8d80 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -65,6 +65,22 @@ str_array_to_word_array (const gchar *str_array[], WordList *word_list) return word_array; } +static void +test_clue_matches (WordList *word_list, + IpuzClue *clue, + IpuzGrid *grid, + const gchar *str_array[]) +{ + g_autoptr (WordArray) clue_matches = NULL; + g_autoptr (WordArray) expected_word_array = NULL; + + clue_matches = word_list_find_clue_matches (word_list, clue, grid); + expected_word_array = str_array_to_word_array (str_array, word_list); + + g_assert (word_array_equals (clue_matches, expected_word_array)); +} + + static void test_egg_ipuz (void) { -- GitLab From 1c79eb1adcd424196fe9a1721e0377cebac42925 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 29 Aug 2025 13:22:33 -0400 Subject: [PATCH 04/16] Rename parameter --- src/clue-matches-tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 35bf8d80..aa78faaa 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -69,13 +69,13 @@ static void test_clue_matches (WordList *word_list, IpuzClue *clue, IpuzGrid *grid, - const gchar *str_array[]) + const gchar *expected_words[]) { g_autoptr (WordArray) clue_matches = NULL; g_autoptr (WordArray) expected_word_array = NULL; clue_matches = word_list_find_clue_matches (word_list, clue, grid); - expected_word_array = str_array_to_word_array (str_array, word_list); + expected_word_array = str_array_to_word_array (expected_words, word_list); g_assert (word_array_equals (clue_matches, expected_word_array)); } -- GitLab From dd694b09ab60360529065ada5dc47d58c156abc3 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Mon, 1 Sep 2025 16:57:07 -0400 Subject: [PATCH 05/16] Add skeleton code for fixtures --- src/clue-matches-tests.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index aa78faaa..e4030fb8 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -31,6 +31,21 @@ #define VALID_INTERSECTION_IPUZ "tests/clue-matches/valid-intersection.ipuz" #define INVALID_INTERSECTION_IPUZ "tests/clue-matches/invalid-intersection.ipuz" +static IpuzGrid* create_grid (const gchar* filename); + +typedef struct { + WordList *word_list; + IpuzGrid *grid; +} Fixture; + +static void fixture_set_up (Fixture *fixture, gconstpointer user_data) +{ +} + +static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) +{ +} + static IpuzGrid* create_grid (const gchar* filename) { -- GitLab From 9bd8e66b9b7065b41e96ff153985fc0a5c3f4768 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Mon, 1 Sep 2025 17:05:25 -0400 Subject: [PATCH 06/16] Add fixture setup and teardown functions --- src/clue-matches-tests.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index e4030fb8..e7578d1c 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -40,10 +40,16 @@ typedef struct { static void fixture_set_up (Fixture *fixture, gconstpointer user_data) { + const gchar *ipuz_file_path = (const gchar *) user_data; + + fixture->word_list = get_broda_word_list (); + fixture->grid = create_grid (ipuz_file_path); } static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) { + g_object_unref (fixture->word_list); + g_object_unref (fixture->grid); } static IpuzGrid* -- GitLab From 62769393612bff5569258f1068b89c772a60a2ab Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Mon, 1 Sep 2025 17:15:05 -0400 Subject: [PATCH 07/16] Fix test_clue_matches() --- src/clue-matches-tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index e7578d1c..f446846e 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -88,10 +88,12 @@ str_array_to_word_array (const gchar *str_array[], WordList *word_list) static void test_clue_matches (WordList *word_list, - IpuzClue *clue, IpuzGrid *grid, + IpuzClueDirection *clue_direction, + guint clue_index, const gchar *expected_words[]) { + g_autofree IpuzClue *clue = NULL; g_autoptr (WordArray) clue_matches = NULL; g_autoptr (WordArray) expected_word_array = NULL; @@ -101,7 +103,6 @@ test_clue_matches (WordList *word_list, g_assert (word_array_equals (clue_matches, expected_word_array)); } - static void test_egg_ipuz (void) { -- GitLab From 2d2c21f05d733390be341e33870a0ae87e438a9c Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Mon, 1 Sep 2025 17:43:48 -0400 Subject: [PATCH 08/16] Change test to use fixture --- src/clue-matches-tests.c | 43 +++++++++++++--------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index f446846e..93ad3e41 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -89,7 +89,7 @@ str_array_to_word_array (const gchar *str_array[], WordList *word_list) static void test_clue_matches (WordList *word_list, IpuzGrid *grid, - IpuzClueDirection *clue_direction, + IpuzClueDirection clue_direction, guint clue_index, const gchar *expected_words[]) { @@ -97,6 +97,7 @@ test_clue_matches (WordList *word_list, g_autoptr (WordArray) clue_matches = NULL; g_autoptr (WordArray) expected_word_array = NULL; + clue = get_clue (grid, clue_direction, clue_index); clue_matches = word_list_find_clue_matches (word_list, clue, grid); expected_word_array = str_array_to_word_array (expected_words, word_list); @@ -104,33 +105,13 @@ test_clue_matches (WordList *word_list, } static void -test_egg_ipuz (void) +test_egg_ipuz (Fixture *fixture, gconstpointer user_data) { - g_autoptr (WordList) word_list = NULL; - IpuzGrid *grid; - g_autofree IpuzClue *clue = NULL; - g_autoptr (WordArray) clue_matches = NULL; - - word_list = get_broda_word_list (); - grid = create_grid (EGG_IPUZ); - clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 2); - clue_matches = word_list_find_clue_matches (word_list, clue, grid); - - g_assert_cmpint (word_array_len (clue_matches), ==, 3); - g_assert_cmpstr (word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 0)), - ==, - "EGGS"); - g_assert_cmpstr ( - word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 1)), - ==, - "EGGO"); - g_assert_cmpstr ( - word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 2)), - ==, - "EGGY"); + test_clue_matches (fixture->word_list, + fixture->grid, + IPUZ_CLUE_DIRECTION_ACROSS, + 2, + (const gchar*[]){"EGGS", "EGOO", "EGGY", NULL}); } static void @@ -197,8 +178,12 @@ int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); - g_test_add_func ("/clue_matches/test_egg_ipuz", - test_egg_ipuz); + g_test_add ("/clue_matches/test_egg_ipuz", + Fixture, + EGG_IPUZ, + fixture_set_up, + test_egg_ipuz, + fixture_tear_down); g_test_add_func ("/clue_matches/valid_intersection_ipuz", test_valid_intersection_ipuz); g_test_add_func ("/clue_matches/invalid_intersection_ipuz", -- GitLab From 16ae704aac7bcb021e25eb8f04a561011db4a036 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 11:16:21 -0400 Subject: [PATCH 09/16] Get first test working with fixture --- src/clue-matches-tests.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 93ad3e41..42f6a2ac 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -48,8 +48,10 @@ static void fixture_set_up (Fixture *fixture, gconstpointer user_data) static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) { - g_object_unref (fixture->word_list); - g_object_unref (fixture->grid); + // g_message ("REF COUNTS %u", G_OBJECT(fixture->word_list)->ref_count); + // g_message ("REF COUNTS %u", G_OBJECT(fixture->grid)->ref_count); + // g_clear_object (&fixture->word_list); + // g_clear_object (&fixture->grid); } static IpuzGrid* @@ -111,7 +113,7 @@ test_egg_ipuz (Fixture *fixture, gconstpointer user_data) fixture->grid, IPUZ_CLUE_DIRECTION_ACROSS, 2, - (const gchar*[]){"EGGS", "EGOO", "EGGY", NULL}); + (const gchar*[]){"EGGS", "EGGO", "EGGY", NULL}); } static void -- GitLab From c3b48aeb8cf3b2e6a251b30344f0422439384b63 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 11:21:37 -0400 Subject: [PATCH 10/16] Get second test working with fixture --- src/clue-matches-tests.c | 63 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 42f6a2ac..4afe182e 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -117,42 +117,18 @@ test_egg_ipuz (Fixture *fixture, gconstpointer user_data) } static void -test_valid_intersection_ipuz (void) +test_valid_intersection_ipuz (Fixture *fixture, gconstpointer user_data) { - g_autoptr (WordList) word_list = NULL; - IpuzGrid *grid; - g_autofree IpuzClue *clue = NULL; - g_autoptr (WordArray) clue_matches = NULL; - - word_list = get_broda_word_list (); - grid = create_grid (VALID_INTERSECTION_IPUZ); - clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 1); - clue_matches = word_list_find_clue_matches (word_list, clue, grid); - - g_assert_cmpint (word_array_len (clue_matches), ==, 2); - g_assert_cmpstr (word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 0)), - ==, - "WORD"); - g_assert_cmpstr (word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 1)), - ==, - "WORM"); - word_array_unref (clue_matches); - - clue = get_clue (grid, IPUZ_CLUE_DIRECTION_DOWN, 3); - clue_matches = word_list_find_clue_matches (word_list, clue, grid); - - g_assert_cmpint (word_array_len (clue_matches), ==, 2); - g_assert_cmpstr (word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 0)), - ==, - "EDIT"); - g_assert_cmpstr ( - word_list_get_indexed_word (word_list, - word_array_index (clue_matches, 1)), - ==, - "EMIT"); + test_clue_matches (fixture->word_list, + fixture->grid, + IPUZ_CLUE_DIRECTION_ACROSS, + 1, + (const gchar*[]){"WORD", "WORM", NULL}); + test_clue_matches (fixture->word_list, + fixture->grid, + IPUZ_CLUE_DIRECTION_DOWN, + 3, + (const gchar*[]){"EDIT", "EMIT", NULL}); } static void @@ -175,7 +151,6 @@ test_invalid_intersection_ipuz (void) /* FIXME(tests): Measure performance. */ /* FIXME(tests): Add more tests. */ -/* FIXME(tests): Refactor these tests to not require so much manual code. */ int main (int argc, char **argv) { @@ -186,9 +161,17 @@ main (int argc, char **argv) fixture_set_up, test_egg_ipuz, fixture_tear_down); - g_test_add_func ("/clue_matches/valid_intersection_ipuz", - test_valid_intersection_ipuz); - g_test_add_func ("/clue_matches/invalid_intersection_ipuz", - test_invalid_intersection_ipuz); + 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); return g_test_run (); } -- GitLab From 18d521294ecfbba594819a68cce61e954570d4cf Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 11:29:30 -0400 Subject: [PATCH 11/16] Get third test working with fixture --- src/clue-matches-tests.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 4afe182e..b9d8f782 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -132,21 +132,18 @@ test_valid_intersection_ipuz (Fixture *fixture, gconstpointer user_data) } static void -test_invalid_intersection_ipuz (void) +test_invalid_intersection_ipuz (Fixture *fixture, gconstpointer user_data) { - g_autoptr (WordList) word_list = NULL; - IpuzGrid *grid; - g_autofree IpuzClue *clue = NULL; - g_autoptr (WordArray) clue_matches = NULL; - - word_list = get_broda_word_list (); - grid = create_grid (INVALID_INTERSECTION_IPUZ); - clue = get_clue (grid, IPUZ_CLUE_DIRECTION_ACROSS, 3); - clue_matches = word_list_find_clue_matches (word_list, clue, grid); - g_assert_cmpint (word_array_len (clue_matches), ==, 0); - clue = get_clue (grid, IPUZ_CLUE_DIRECTION_DOWN, 3); - clue_matches = word_list_find_clue_matches (word_list, clue, grid); - g_assert_cmpint (word_array_len (clue_matches), ==, 0); + test_clue_matches (fixture->word_list, + fixture->grid, + IPUZ_CLUE_DIRECTION_ACROSS, + 3, + (const gchar*[]){NULL}); + test_clue_matches (fixture->word_list, + fixture->grid, + IPUZ_CLUE_DIRECTION_DOWN, + 3, + (const gchar*[]){NULL}); } /* FIXME(tests): Measure performance. */ @@ -167,11 +164,11 @@ main (int argc, char **argv) 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); + g_test_add ("/clue_matches/invalid_intersection_ipuz", + Fixture, + INVALID_INTERSECTION_IPUZ, + fixture_set_up, + test_invalid_intersection_ipuz, + fixture_tear_down); return g_test_run (); } -- GitLab From 4ff2c9fed236c16f826a5298358eb4a8b1bf29b0 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 13:09:04 -0400 Subject: [PATCH 12/16] Fix teardown function --- src/clue-matches-tests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index b9d8f782..c0687d9d 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -25,8 +25,6 @@ #include "word-list-test-utils.h" #include "test-utils.h" -// #define _TEST_FILE "tests/clue-matches/.ipuz" - #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" @@ -48,10 +46,12 @@ static void fixture_set_up (Fixture *fixture, gconstpointer user_data) static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) { - // g_message ("REF COUNTS %u", G_OBJECT(fixture->word_list)->ref_count); - // g_message ("REF COUNTS %u", G_OBJECT(fixture->grid)->ref_count); - // g_clear_object (&fixture->word_list); - // g_clear_object (&fixture->grid); + g_object_unref (fixture->word_list); + /* If I try to free the grid: + * g_object_unref (fixture->grid); + * I get this error: + * GLib-FATAL-CRITICAL: g_ref_count_dec: assertion 'rrc < 0' failed + */ } static IpuzGrid* -- GitLab From 67f17d0257868a85de5cd8235a7b9531afc7cf25 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 13:20:11 -0400 Subject: [PATCH 13/16] Move create_grid() up --- src/clue-matches-tests.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index c0687d9d..429ad2ab 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -29,13 +29,18 @@ #define VALID_INTERSECTION_IPUZ "tests/clue-matches/valid-intersection.ipuz" #define INVALID_INTERSECTION_IPUZ "tests/clue-matches/invalid-intersection.ipuz" -static IpuzGrid* create_grid (const gchar* filename); - typedef struct { WordList *word_list; IpuzGrid *grid; } Fixture; +static IpuzGrid* +create_grid (const gchar* filename) +{ + GridState *state = (load_state (filename, GRID_STATE_EDIT)); + return IPUZ_GRID (state->xword); +} + static void fixture_set_up (Fixture *fixture, gconstpointer user_data) { const gchar *ipuz_file_path = (const gchar *) user_data; @@ -54,13 +59,6 @@ static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) */ } -static IpuzGrid* -create_grid (const gchar* filename) -{ - GridState *state = (load_state (filename, GRID_STATE_EDIT)); - return IPUZ_GRID (state->xword); -} - static IpuzClue* get_clue (IpuzGrid* grid, IpuzClueDirection direction, guint index) { -- GitLab From f35516166ab253f1b6642e6b99ade1a7e21d577b Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 13:25:47 -0400 Subject: [PATCH 14/16] Use g_assert_true() --- src/clue-matches-tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 429ad2ab..69d34559 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -80,7 +80,7 @@ str_array_to_word_array (const gchar *str_array[], WordList *word_list) gboolean success = word_list_lookup_index (word_list, str_array[i], &word_index); - g_assert (success); + g_assert_true (success); word_array_add (word_array, word_index); } return word_array; @@ -101,7 +101,7 @@ test_clue_matches (WordList *word_list, clue_matches = word_list_find_clue_matches (word_list, clue, grid); expected_word_array = str_array_to_word_array (expected_words, word_list); - g_assert (word_array_equals (clue_matches, expected_word_array)); + g_assert_true (word_array_equals (clue_matches, expected_word_array)); } static void -- GitLab From 4c86f45304d7f78b50bd5eda4d20380cf9551160 Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Tue, 2 Sep 2025 13:33:30 -0400 Subject: [PATCH 15/16] Add newline --- src/clue-matches-tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 69d34559..60399bc9 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -52,6 +52,7 @@ static void fixture_set_up (Fixture *fixture, gconstpointer user_data) static void fixture_tear_down (Fixture *fixture, gconstpointer user_data) { g_object_unref (fixture->word_list); + /* If I try to free the grid: * g_object_unref (fixture->grid); * I get this error: -- GitLab From 2ef6a1ff33ef2849f2a9e236542d1662c5e4e84a Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 19 Sep 2025 18:47:40 -0400 Subject: [PATCH 16/16] Remove bad g_autofree --- src/clue-matches-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clue-matches-tests.c b/src/clue-matches-tests.c index 60399bc9..e7dd49e0 100644 --- a/src/clue-matches-tests.c +++ b/src/clue-matches-tests.c @@ -94,7 +94,7 @@ test_clue_matches (WordList *word_list, guint clue_index, const gchar *expected_words[]) { - g_autofree IpuzClue *clue = NULL; + const IpuzClue *clue = NULL; g_autoptr (WordArray) clue_matches = NULL; g_autoptr (WordArray) expected_word_array = NULL; -- GitLab