This is a test post
Over the past few weeks, I’ve been working on improving some test code that I had written.
Refactoring time!
My first order of business was to refactor the test code. There was a lot of boilerplate, which made it difficult to add new tests, and also created visual clutter.
For example, have a look at this test case:
static void
test_egg_ipuz (void)
{
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_FILE_PATH);
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");
}
That’s an awful lot of code just to say:
Read more...