[glib: 7/16] tests: Encode invalid UTF-8 before outputted in a test message




commit 011202dbc59bcf8480508370afc4776f31f1bb0e
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Jun 14 18:34:55 2022 +0100

    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>

 glib/tests/uri.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/uri.c b/glib/tests/uri.c
index 0b9ca1a9ff..cf209efd0f 100644
--- a/glib/tests/uri.c
+++ b/glib/tests/uri.c
@@ -479,14 +479,16 @@ test_uri_escape_string (void)
   for (i = 0; i < G_N_ELEMENTS (tests); i++)
     {
       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,
                                tests[i].reserved_chars_allowed,
                                tests[i].allow_utf8);
       g_assert_cmpstr (s, ==, tests[i].expected_escaped);
       g_free (s);
+      g_free (escaped);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]