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-break.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'tests/test-break.c') diff --git a/tests/test-break.c b/tests/test-break.c index 8549b678..f4faaab3 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -51,12 +51,8 @@ test_file (const gchar *filename, GString *string) PangoAttrList *attributes; PangoLayout *layout; - 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; @@ -68,12 +64,8 @@ test_file (const gchar *filename, GString *string) len = g_utf8_strlen (test, -1) + 1; attrs = g_new (PangoLogAttr, len); - if (!pango_parse_markup (test, -1, 0, &attributes, &text, NULL, &error)) - { - fprintf (stderr, "%s\n", error->message); - g_error_free (error); - return; - } + pango_parse_markup (test, -1, 0, &attributes, &text, NULL, &error); + g_assert_no_error (error); layout = pango_layout_new (context); pango_layout_set_text (layout, text, length); @@ -260,7 +252,8 @@ test_break (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); } @@ -291,7 +284,7 @@ main (int argc, char *argv[]) string = g_string_sized_new (0); test_file (argv[1], string); - printf ("%s", string->str); + g_test_message ("%s", string->str); return 0; } -- cgit v1.2.1