[pango/ligature-caret-rtl-fixes: 3/7] test-itemize: Add --hex-chars option




commit 974ad21cc7418a2105d02b2ec988ba3435b8db80
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 27 10:52:45 2021 -0400

    test-itemize: Add --hex-chars option
    
    This is useful here too.

 tests/test-itemize.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 105b453d..f91af30c 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -34,6 +34,8 @@
 
 static PangoContext *context;
 
+static gboolean opt_hex_chars;
+
 static void
 append_text (GString    *s,
              const char *text,
@@ -44,7 +46,11 @@ append_text (GString    *s,
   for (p = text; p < text + len; p = g_utf8_next_char (p))
     {
       gunichar ch = g_utf8_get_char (p);
-      if (ch == 0x0A || ch == 0x2028 || !g_unichar_isprint (ch))
+      if (ch == ' ')
+        g_string_append (s, "[ ]");
+      else if (opt_hex_chars)
+        g_string_append_printf (s, "[%#04x]", ch);
+      else if (ch == 0x0A || ch == 0x2028 || !g_unichar_isprint (ch))
         g_string_append_printf (s, "[%#04x]", ch);
       else
         g_string_append_unichar (s, ch);
@@ -312,6 +318,21 @@ main (int argc, char *argv[])
   GError *error = NULL;
   const gchar *name;
   gchar *path;
+  GOptionContext *option_context;
+  GOptionEntry entries[] = {
+    { "hex-chars", '0', 0, G_OPTION_ARG_NONE, &opt_hex_chars, "Print all chars in hex", NULL },
+    { NULL, 0, },
+  };
+
+  option_context = g_option_context_new ("");
+  g_option_context_add_main_entries (option_context, entries, NULL);
+  g_option_context_set_ignore_unknown_options (option_context, TRUE);
+  if (!g_option_context_parse (option_context, &argc, &argv, &error))
+    {
+      g_error ("failed to parse options: %s", error->message);
+      return 1;
+    }
+  g_option_context_free (option_context);
 
   g_test_init (&argc, &argv, NULL);
 


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