From 3fc1a9bff1892f92d96bcf1fb86c157885673396 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 14 Apr 2020 13:11:49 +0100 Subject: tests: Use the appropriate GTest API Do not use homegrown assertion and failure macros, when GTest has perfectly functional API to deal with all the cases Pango covers. Using GTest also allows us to rely on appropriate formatting for results and logging. --- tests/test-itemize.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'tests/test-itemize.c') diff --git a/tests/test-itemize.c b/tests/test-itemize.c index d66c40d1..167e4e80 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -118,12 +118,8 @@ test_file (const gchar *filename, GString *string) GList *items, *l; const char *sep = ""; - if (!g_file_get_contents (filename, &contents, &length, &error)) - { - fprintf (stderr, "%s\n", error->message); - g_error_free (error); - return; - } + g_file_get_contents (filename, &contents, &length, &error); + g_assert_no_error (error); test = contents; @@ -131,13 +127,8 @@ test_file (const gchar *filename, GString *string) while (test[0] == '#') test = strchr (test, '\n') + 1; - - if (!pango_parse_markup (test, -1, 0, &attrs, &text, NULL, &error)) - { - fprintf (stderr, "%s\n", error->message); - g_error_free (error); - return; - } + pango_parse_markup (test, -1, 0, &attrs, &text, NULL, &error); + g_assert_no_error (error); s1 = g_string_new ("Items: "); s2 = g_string_new ("Font: "); @@ -257,7 +248,8 @@ test_itemize (gconstpointer d) if (diff && diff[0]) { - g_printerr ("Contents don't match expected contents:\n%s", diff); + g_test_message ("Contents don't match expected contents"); + g_test_message ("%s", diff); g_test_fail (); g_free (diff); } -- cgit v1.2.1