diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-04-14 13:11:49 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-04-14 13:13:51 +0100 |
commit | 3fc1a9bff1892f92d96bcf1fb86c157885673396 (patch) | |
tree | 209a6db48983052ef79396e09041f13c9f6f7a85 /tests/testscript.c | |
parent | 2a773323f1f7b5510ee0de7a1ea0ac8bec0e05d4 (diff) | |
download | pango-3fc1a9bff1892f92d96bcf1fb86c157885673396.tar.gz |
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.
Diffstat (limited to 'tests/testscript.c')
-rw-r--r-- | tests/testscript.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/tests/testscript.c b/tests/testscript.c index aa610b44..33e8ad2e 100644 --- a/tests/testscript.c +++ b/tests/testscript.c @@ -60,18 +60,6 @@ #include "pango/pango-script.h" -#undef VERBOSE - -#define ASSERT(stmt) G_STMT_START { \ - if (stmt) { } \ - else \ - { \ - g_warning ("%s:%d (%s): assertion '%s' failed", \ - __FILE__, __LINE__, G_STRFUNC, #stmt); \ - exit (1); \ - } \ -} G_STMT_END - typedef struct { const char *run_text_escaped; @@ -170,9 +158,7 @@ test_script_iter (void) iter = pango_script_iter_new (all->str, -1); -#ifdef VERBOSE - g_print ("Total length: %d\n", all->len); -#endif + g_test_message ("Total length: %" G_GSIZE_FORMAT "\n", all->len); pos = all->str; for (i = 0; i < G_N_ELEMENTS(test_data); i++) @@ -181,16 +167,18 @@ test_script_iter (void) gboolean result; pango_script_iter_get_range (iter, &start, &end, &script); -#ifdef VERBOSE - g_print ("Range: %d-%d: %d\n", start - all->str, end - all->str, script); -#endif - ASSERT (start == pos); - ASSERT (end == next_pos); - ASSERT (script == test_data[i].run_code); + g_test_message ("Range: %d-%d: %d\n", + (int) (start - all->str), + (int) (end - all->str), + script); + + g_assert_true (start == pos); + g_assert_true (end == next_pos); + g_assert_true (script == test_data[i].run_code); result = pango_script_iter_next (iter); - ASSERT (result == (i != G_N_ELEMENTS (test_data) - 1)); + g_assert_true (result == (i != G_N_ELEMENTS (test_data) - 1)); pos = next_pos; } @@ -204,10 +192,10 @@ test_script_iter (void) pango_script_iter_get_range (iter, &start, &end, &script); - ASSERT (start == all->str); - ASSERT (end == all->str); - ASSERT (script == PANGO_SCRIPT_COMMON); - ASSERT (!pango_script_iter_next (iter)); + g_assert_true (start == all->str); + g_assert_true (end == all->str); + g_assert_true (script == PANGO_SCRIPT_COMMON); + g_assert_true (!pango_script_iter_next (iter)); pango_script_iter_free (iter); |