tests: Encode invalid UTF-8 before outputted in a test message

`g_test_message()` requires correctly encoded arguments, but some of the
strings in the `uri` test are (deliberately) not valid UTF-8. Encode
them before printing them.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2022-06-14 18:34:55 +01:00
parent b82bfe7642
commit 011202dbc5

View File

@ -479,14 +479,16 @@ test_uri_escape_string (void)
for (i = 0; i < G_N_ELEMENTS (tests); i++) for (i = 0; i < G_N_ELEMENTS (tests); i++)
{ {
gchar *s = NULL; gchar *s = NULL;
gchar *escaped = g_strescape (tests[i].unescaped, NULL);
g_test_message ("Test %" G_GSIZE_FORMAT ": %s", i, tests[i].unescaped); g_test_message ("Test %" G_GSIZE_FORMAT ": %s", i, escaped);
s = g_uri_escape_string (tests[i].unescaped, s = g_uri_escape_string (tests[i].unescaped,
tests[i].reserved_chars_allowed, tests[i].reserved_chars_allowed,
tests[i].allow_utf8); tests[i].allow_utf8);
g_assert_cmpstr (s, ==, tests[i].expected_escaped); g_assert_cmpstr (s, ==, tests[i].expected_escaped);
g_free (s); g_free (s);
g_free (escaped);
} }
} }