[pango/line-breaking-fixes: 21/21] testrandom: Add other wrap modes




commit 242e6945f5ac79db49064989bbc118b985c1aa6a
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 12 21:39:29 2021 -0500

    testrandom: Add other wrap modes

 tests/testrandom.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/tests/testrandom.c b/tests/testrandom.c
index 9f132b92..643692ff 100644
--- a/tests/testrandom.c
+++ b/tests/testrandom.c
@@ -93,10 +93,10 @@ layout_check_size (PangoLayout *layout,
 }
 
 static void
-test_wrap_char (gconstpointer data)
+test_random (PangoDirection dir,
+             PangoWrapMode  wrap)
 {
 #define N_SENTENCES 20
-  PangoDirection dir = GPOINTER_TO_UINT (data);
   PangoFontDescription *desc;
   PangoContext *context;
   PangoLayout *layout;
@@ -118,7 +118,7 @@ test_wrap_char (gconstpointer data)
       if (g_test_verbose ())
         g_print ("%s\n", sentence);
       g_free (sentence);
-      pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
+      pango_layout_set_wrap (layout, wrap);
 
       layout_check_size (layout, -1, &max);
       layout_check_size (layout, 0, &min);
@@ -176,6 +176,27 @@ test_wrap_char (gconstpointer data)
   g_object_unref (context);
 }
 
+static void
+test_wrap_word_char (gconstpointer data)
+{
+  PangoDirection dir = GPOINTER_TO_UINT (data);
+  test_random (dir, PANGO_WRAP_WORD_CHAR);
+}
+
+static void
+test_wrap_char (gconstpointer data)
+{
+  PangoDirection dir = GPOINTER_TO_UINT (data);
+  test_random (dir, PANGO_WRAP_CHAR);
+}
+
+static void
+test_wrap_word (gconstpointer data)
+{
+  PangoDirection dir = GPOINTER_TO_UINT (data);
+  test_random (dir, PANGO_WRAP_WORD);
+}
+
 static gboolean
 load_hunspell_words (GStrvBuilder *builder,
                       const char  *language)
@@ -280,9 +301,15 @@ main (int argc, char *argv[])
   rtl_words = init_rtl_words ();
   n_rtl_words = g_strv_length (rtl_words);
 
+  g_test_add_data_func ("/layout/ltr/wrap-word-char", GUINT_TO_POINTER (PANGO_DIRECTION_LTR), 
test_wrap_word_char);
+  g_test_add_data_func ("/layout/rtl/wrap-word-char", GUINT_TO_POINTER (PANGO_DIRECTION_RTL), 
test_wrap_word_char);
+  g_test_add_data_func ("/layout/any/wrap-word-char", GUINT_TO_POINTER (PANGO_DIRECTION_NEUTRAL), 
test_wrap_word_char);
   g_test_add_data_func ("/layout/ltr/wrap-char", GUINT_TO_POINTER (PANGO_DIRECTION_LTR), test_wrap_char);
   g_test_add_data_func ("/layout/rtl/wrap-char", GUINT_TO_POINTER (PANGO_DIRECTION_RTL), test_wrap_char);
   g_test_add_data_func ("/layout/any/wrap-char", GUINT_TO_POINTER (PANGO_DIRECTION_NEUTRAL), test_wrap_char);
+  g_test_add_data_func ("/layout/ltr/wrap-word", GUINT_TO_POINTER (PANGO_DIRECTION_LTR), test_wrap_word);
+  g_test_add_data_func ("/layout/rtl/wrap-word", GUINT_TO_POINTER (PANGO_DIRECTION_RTL), test_wrap_word);
+  g_test_add_data_func ("/layout/any/wrap-word", GUINT_TO_POINTER (PANGO_DIRECTION_NEUTRAL), test_wrap_word);
 
   result = g_test_run ();
 


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