[pango/tests-and-fixes: 5/7] tests: Dump grapheme boundaries too




commit 628c950fa07e31d01f33c1a17e6772f5b870e847
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jul 7 18:10:00 2021 -0400

    tests: Dump grapheme boundaries too
    
    Add grapheme boundaries to the output of test-break,
    so we can check those easily, too.
    
    Update expected test output for this.

 tests/breaks/eight.expected |  6 ++++++
 tests/breaks/five.expected  |  6 ++++++
 tests/breaks/four.expected  |  1 +
 tests/breaks/nine.expected  |  1 +
 tests/breaks/one.expected   |  1 +
 tests/breaks/seven.expected |  6 ++++++
 tests/breaks/six.expected   |  6 ++++++
 tests/breaks/ten.expected   |  1 +
 tests/breaks/three.expected |  1 +
 tests/breaks/two.expected   |  1 +
 tests/test-break.c          | 27 ++++++++++++++++++++++-----
 11 files changed, 52 insertions(+), 5 deletions(-)
---
diff --git a/tests/breaks/eight.expected b/tests/breaks/eight.expected
new file mode 100644
index 00000000..083ebeef
--- /dev/null
+++ b/tests/breaks/eight.expected
@@ -0,0 +1,6 @@
+Text:         我  能  吞  下  玻  璃  而  不  傷  身  體  [0x0a] 
+Breaks:     c  lc lc lc lc lc lc lc lc lc lc c       c
+Whitespace:                                  w       w
+Words:      bs b  b  b  b  b  b  b  b  b  b  be      b
+Sentences:  bs                               e       b
+Graphemes:  b  b  b  b  b  b  b  b  b  b  b  b       b
diff --git a/tests/breaks/five.expected b/tests/breaks/five.expected
new file mode 100644
index 00000000..38dc88ff
--- /dev/null
+++ b/tests/breaks/five.expected
@@ -0,0 +1,6 @@
+Text:         H e r e  [ ]  i s  [ ]  s o m e  [ ]  t e x t  [ ]  w i t h  [ ]  b r e a k  -  a f f e c t i 
n g  [ ]  a t t r i b u t e s  . [0x0a] 
+Breaks:     c  c c c c    lc c c    lc c c c c    lc c c c c    lc                                           
                                      c
+Whitespace:          x         x             x             x             x                                   
  x                            w      w
+Words:      bs       be   bs   be   bs       be   bs       be   bs       be   bs         be bs               
  be   bs                   be b      b
+Sentences:  bs                                                                                               
                               e      b
+Graphemes:  b  b b b b    b  b b    b  b b b b    b  b b b b    b  b b b b    b  b b b b b  b  b b b b b b b 
b b    b  b b b b b b b b b b  b      b
diff --git a/tests/breaks/four.expected b/tests/breaks/four.expected
index 6d3d1ba4..100eae24 100644
--- a/tests/breaks/four.expected
+++ b/tests/breaks/four.expected
@@ -3,3 +3,4 @@ Breaks:     c  c c c lc  c c c    lc  c  c c    lc  c c c lc  c c lc  c c c c
 Whitespace:                  x             x                                x                                
                                                                          x                                   
                                                                                                              
    x          x                             x                                                                
                                                             x                                                
                          x                                                                                   
                                 x                        x                                                   
    x                                          x               w       w
 Words:      bs b b b bse b b be   bse b  b be   bse b b b bse b b bse b b b be   bse b  b bse b b b bse b b 
b b b bse b b bse b b b bse b b b b bse b b  bse b b bse b b b b b bse b b be   bse b b b bse b b bse b  b 
bse b b b bse b bse b   b bse b b b bse b bse   b bse b  b bse b   b bse  b b bse b b bse b b b  b bse b b b 
bse b  b be   bse b be   bse  b b  b b b b bse  b be   bse b b b bse b bse b b b  b bse   bse  bse   b bse b 
b b  b bse b b bse b b bse b b bse b  bse b b bse b b b b b bse  b be   bse b b bse  b bse b b b b b b b b  
bse b b bse  b b bse b b b bse  b be   bse b b b bse b b bse  b bse b bse  bse b b b bse b   b b bse b b bse  
b bse b b b  b bse b b b bse b bse b b b be   bse b b b  b bse  b be   bse b b b  b bse b b b bse b bse b b b 
b  b b  b b be   bse b b bse b b b  b bse b b b bse  b be   bse  b b b be      b
 Sentences:  bs                                                                                               
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                                                                              
                                                               e       b
+Graphemes:  b  b b b b   b b b    b   b  b b    b   b b b b   b b b   b b b b    b   b  b b   b b b b   b b 
b b b b   b b b   b b b b   b b b b b   b b  b   b b b   b b b b b b   b b b    b   b b b b   b b b   b  b b  
 b b b b   b b   b   b b   b b b b   b b     b b   b  b b   b   b b    b b b   b b b   b b b  b b   b b b b   
b  b b    b   b b    b    b b  b b b b b    b b    b   b b b b   b b   b b b  b b     b    b     b b   b b b  
b b   b b b   b b b   b b b   b  b   b b b   b b b b b b    b b    b   b b b    b b   b b b b b b b b  b   b 
b b    b b b   b b b b    b b    b   b b b b   b b b    b b   b b    b   b b b b   b   b b b   b b b    b b   
b b b  b b   b b b b   b b   b b b b    b   b b b  b b    b b    b   b b b  b b   b b b b   b b   b b b b  b 
b  b b b    b   b b b   b b b  b b   b b b b    b b    b    b b b b       b
diff --git a/tests/breaks/nine.expected b/tests/breaks/nine.expected
index 7f38803d..8ffac505 100644
--- a/tests/breaks/nine.expected
+++ b/tests/breaks/nine.expected
@@ -3,3 +3,4 @@ Breaks:     c   c    lc  c c    lc  c c    lc c c  c  c   lc c  c    lc  c    lc
 Whitespace:     x          x          x               x         x        x            x          w           
 x           x        x            x            x          x         x        x          x           x        
   x          w              x                x                          x              x               x     
     x              x            w              x             x           x             x           x         
  x             x               x             x             x    w           x             x               x  
          x          x         x         x               w       w
 Words:      bs  be   bs    be   bs    be   bs      be b   bs    be   bs  be   bs      be   bs    be      bs  
 be   bs     be   bs  be   bs      be   bs   be b   bs     be   bs   be   bs  be   bs    be   bs     be   bs  
   be   bs    be      bs     be   bs          be   bs                 be b   bs         be   bs         be   
bs    be   bs        be   bs      be      bs     be   bs       be   bs     be   bs       be   bs     be   bs  
   be   bs       be   bs         be   bs       be   bs       be   b      bs   be   bs       be   bs         
be   bs   be b   bs     be   bs   be   bs   be   bs         be      b
 Sentences:  bs                                                                                   e       bs  
                                                                                                              
              e       bs                                                                                      
                                 e       bs                                                                   
                                                            e           bs                                    
                                                         e       b
+Graphemes:  b   b    b   b b    b   b b    b  b b  b  b   b  b  b    b   b    b   b b b    b   b b       b   
 b    b    b b    b   b    b  b b  b    b    b  b   b   b  b    b  b b    b   b    b   b b    b   b  b    b  
b   b    b   b b       b   b  b    b  b  b  b  b    b   b  b  b  b  b  b  b   b  b b  b  b    b  b b  b  b    
b  b  b    b   b  b  b    b  b  b b       b  b b b    b  b b b b    b  b b b    b  b b b b    b  b b b    b  
b b b    b  b b b b    b  b b b b b    b  b b b b    b  b b b b    b      b  b b    b  b b b b    b  b b b b 
b    b  b b  b   b  b b b    b  b b    b  b b    b  b b b b b       b
diff --git a/tests/breaks/one.expected b/tests/breaks/one.expected
index 66c6bd48..165e2d13 100644
--- a/tests/breaks/one.expected
+++ b/tests/breaks/one.expected
@@ -3,3 +3,4 @@ Breaks:     c  c c c  lc c c c    lc c c c      lc c c c  c   lc c c c       c
 Whitespace:                  x                            x          w       w
 Words:      bs     be bs     be   bs                   be b   bs     be      b
 Sentences:  bs                                            e   bs     e       b
+Graphemes:  b  b b b  b  b b b    b  b b b      b  b b b  b   b  b b b       b
diff --git a/tests/breaks/seven.expected b/tests/breaks/seven.expected
new file mode 100644
index 00000000..8cd411a6
--- /dev/null
+++ b/tests/breaks/seven.expected
@@ -0,0 +1,6 @@
+Text:         나  는  [ ]  유  리  를  [ ]  먹  을  [ ]  수  [ ]  있  어  요  . [ ]  그  래  도  [ ]  아  프  지  [ ]  않  아  
요  [0x0a] 
+Breaks:     c  lc c    lc lc lc c    lc lc c    lc c    lc lc lc c  c   lc lc lc c    lc lc lc c    lc lc lc 
c       c
+Whitespace:       x             x          x       x                x            x             x             
w       w
+Words:      bs    be   bs       be   bs    be   bs be   bs       be b   bs       be   bs       be   bs       
be      b
+Sentences:  bs                                                      e   bs                                   
e       b
+Graphemes:  b  b  b    b  b  b  b    b  b  b    b  b    b  b  b  b  b   b  b  b  b    b  b  b  b    b  b  b  
b       b
diff --git a/tests/breaks/six.expected b/tests/breaks/six.expected
new file mode 100644
index 00000000..fba8e60d
--- /dev/null
+++ b/tests/breaks/six.expected
@@ -0,0 +1,6 @@
+Text:         मी  [ ]  का च  [ ]  खा ऊ  [ ]  श क तो  , [ ]  म ला  [ ]  ते  [ ]  दु ख त  [ ]  ना ह  [0x0a]  
मैं  [ ]  काँ च  [ ]  खा  [ ]  स क ता  [ ]  हूँ  , [ ]  मु झे  [ ]  उ स  [ ]  से  [ ]  को ई  [ ]  पी डा  [ ]  
न हीं  [ ]  हो त  [0x0a]  நா ன்  [ ]  க ண் ணா டி  [ ]  சா ப் பி டு வே ன்  , [ ]  அ த னா ல்  [ ]  எ ன க் கு  [ 
]  ஒ ரு  [ ]  கே டு ம்  [ ]  வ ரா த  [0x0a]  ﻢ ﯾ ں  [ ]  ﮎ ﺎ ﻨ ﭼ  [ ]  ﮎ ھ ﺍ  [ ]  ﺲ ﮑ ﺗ ﺍ  [ ]  ہ ﻭ ں  [ ]  
ﺍ ﻭ ﺭ  [ ]  ﻢ ﺟ ھ ے  [ ]  ﺖ ﮑ ﻠ ﯿ ﻓ  [ ]  ﻥ ہ ﯼ ں  [ ]  ہ ﻮ ﺘ ﯾ  [ ] ۔ [0x0a]  ﺰ ﻫ  [ ]  ﺶ ﻴ ﺸ ﻫ  [ ]  ﺥ ﻭ ړ 
ﻝ ې  [ ]  ﺶ ﻣ  ، [ ]  ﻪ ﻐ ﻫ  [ ]  ﻡ ﺍ  [ ]  ﻦ ﻫ  [ ]  ﺥ ﻭ ږ ﻮ ﻳ  [0x0a] 
+Breaks:     c   c    lc  c c    lc  c c    lc c c  c  c   lc c  c    lc  c    lc  c c c    lc  c c       c   
 c    lc   c c    lc  c    lc c c  c    lc   c  c   lc  c  c    lc c c    lc  c    lc  c c    lc  c  c    lc 
c   c    lc  c c       c   c  c    lc c  c  c  c    lc  c  c  c  c  c  c  c   lc c c  c  c    lc c c  c  c    
lc c  c    lc  c  c  c    lc c  c c       c  c c c    lc c c c c    lc c c c    lc c c c c    lc c c c    lc 
c c c    lc c c c c    lc c c c c c    lc c c c c    lc c c c c    c c      c  c c    lc c c c c    lc c c c 
c c    lc c c  c   lc c c c    lc c c    lc c c    lc c c c c c       c
+Whitespace:     x          x          x               x         x        x            x          w           
 x           x        x            x            x          x         x        x          x           x        
   x          w              x                x                          x              x               x     
     x              x            w              x             x           x             x           x         
  x             x               x             x             x      w           x             x               
x            x          x         x         x               w       w
+Words:      bs  be   bs    be   bs    be   bs      be b   bs    be   bs  be   bs      be   bs    be      bs  
 be   bs     be   bs  be   bs      be   bs   be b   bs     be   bs   be   bs  be   bs    be   bs     be   bs  
   be   bs    be      bs     be   bs          be   bs                 be b   bs         be   bs         be   
bs    be   bs        be   bs      be      bs     be   bs       be   bs     be   bs       be   bs     be   bs  
   be   bs       be   bs         be   bs       be   bs       be   b b      bs   be   bs       be   bs         
be   bs   be b   bs     be   bs   be   bs   be   bs         be      b
+Sentences:  bs                                                                                   e       bs  
                                                                                                              
              e       bs                                                                                      
                                 e       bs                                                                   
                                                                   e      bs                                  
                                                           e       b
+Graphemes:  b   b    b   b b    b   b b    b  b b  b  b   b  b  b    b   b    b   b b b    b   b b       b   
 b    b    b b    b   b    b  b b  b    b    b  b   b   b  b    b  b b    b   b    b   b b    b   b  b    b  
b   b    b   b b       b   b  b    b  b  b  b  b    b   b  b  b  b  b  b  b   b  b b  b  b    b  b b  b  b    
b  b  b    b   b  b  b    b  b  b b       b  b b b    b  b b b b    b  b b b    b  b b b b    b  b b b    b  
b b b    b  b b b b    b  b b b b b    b  b b b b    b  b b b b    b b      b  b b    b  b b b b    b  b b b 
b b    b  b b  b   b  b b b    b  b b    b  b b    b  b b b b b       b
diff --git a/tests/breaks/ten.expected b/tests/breaks/ten.expected
index 29f46183..6577c9fb 100644
--- a/tests/breaks/ten.expected
+++ b/tests/breaks/ten.expected
@@ -3,3 +3,4 @@ Breaks:     c  c           c    lc         c  c       c
 Whitespace:                x                  w       w
 Words:      bs             be   bs            be      b
 Sentences:  bs                                e       b
+Graphemes:  b  b           b    b          b  b       b
diff --git a/tests/breaks/three.expected b/tests/breaks/three.expected
index 0e60f876..2ff60a9c 100644
--- a/tests/breaks/three.expected
+++ b/tests/breaks/three.expected
@@ -3,3 +3,4 @@ Breaks:     c  c c c    lc c c c         Lc c c c    lc c c c         c c c c c
 Whitespace:        x           w                x                               w       w
 Words:      bs     be   bs     be        bs     be   bs                         be      b
 Sentences:  bs                 e         bs                                     e       b
+Graphemes:  b  b b b    b  b b b         b  b b b    b  b b b         b b b b b b       b
diff --git a/tests/breaks/two.expected b/tests/breaks/two.expected
index 7ff48c28..c7f983ee 100644
--- a/tests/breaks/two.expected
+++ b/tests/breaks/two.expected
@@ -3,3 +3,4 @@ Breaks:     c  c c c c c c c c c       c
 Whitespace:                    w       w
 Words:      bs         e s     be      b
 Sentences:  bs                 e       b
+Graphemes:  b  b b b b b b b b b       b
diff --git a/tests/test-break.c b/tests/test-break.c
index b06fb4c0..0158bd40 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -46,7 +46,7 @@ test_file (const gchar *filename, GString *string)
   int len2;
   char *p;
   int i;
-  GString *s1, *s2, *s3, *s4;
+  GString *s1, *s2, *s3, *s4, *s5;
   int m;
   char *test;
   char *text;
@@ -73,6 +73,7 @@ test_file (const gchar *filename, GString *string)
   pango_layout_set_text (layout, text, length);
   pango_layout_set_attributes (layout, attributes);
 
+#if 0
   if (pango_layout_get_unknown_glyphs_count (layout) > 0)
     {
       char *msg = g_strdup_printf ("Missing glyphs - skipping %s. Maybe fonts are missing?", filename);
@@ -87,6 +88,7 @@ test_file (const gchar *filename, GString *string)
       g_free (text);
       return FALSE;
     }
+#endif
 
   pango_layout_get_log_attrs (layout, &attrs, &len);
   attrs2 = pango_layout_get_log_attrs_readonly (layout, &len2);
@@ -106,15 +108,17 @@ test_file (const gchar *filename, GString *string)
   s2 = g_string_new ("Whitespace: ");
   s3 = g_string_new ("Words:");
   s4 = g_string_new ("Sentences:");
+  s5 = g_string_new ("Graphemes:");
 
   g_string_append (string, "Text: ");
 
-  m = MAX (MAX (s1->len, s2->len), MAX (s3->len, s4->len));
+  m = MAX (MAX (MAX (s1->len, s2->len), MAX (s3->len, s4->len)), s5->len);
 
   g_string_append_printf (s1, "%*s", (int)(m - s1->len), "");
   g_string_append_printf (s2, "%*s", (int)(m - s2->len), "");
   g_string_append_printf (s3, "%*s", (int)(m - s3->len), "");
   g_string_append_printf (s4, "%*s", (int)(m - s4->len), "");
+  g_string_append_printf (s5, "%*s", (int)(m - s5->len), "");
   g_string_append_printf (string, "%*s", (int)(m - strlen ("Text: ")), "");
 
   for (i = 0, p = text; i < len; i++, p = g_utf8_next_char (p))
@@ -124,6 +128,7 @@ test_file (const gchar *filename, GString *string)
       int w = 0;
       int o = 0;
       int s = 0;
+      int g = 0;
 
       if (log.is_mandatory_break)
         {
@@ -183,14 +188,20 @@ test_file (const gchar *filename, GString *string)
           g_string_append (s4, "e");
           s++;
         }
+      if (log.is_cursor_position)
+        {
+          g_string_append (s5, "b");
+          g++;
+        }
 
-      m = MAX (MAX (b, w), MAX (o, s));
+      m = MAX (MAX (MAX (b, w), MAX (o, s)), g);
 
       g_string_append_printf (string, "%*s", m, "");
       g_string_append_printf (s1, "%*s", m - b, "");
       g_string_append_printf (s2, "%*s", m - w, "");
       g_string_append_printf (s3, "%*s", m - o, "");
       g_string_append_printf (s4, "%*s", m - s, "");
+      g_string_append_printf (s5, "%*s", m - g, "");
 
       if (i < len - 1)
         {
@@ -202,6 +213,7 @@ test_file (const gchar *filename, GString *string)
               g_string_append (s2, "   ");
               g_string_append (s3, "   ");
               g_string_append (s4, "   ");
+              g_string_append (s5, "   ");
             }
           else if (g_unichar_isgraph (ch) &&
                    !(g_unichar_type (ch) == G_UNICODE_LINE_SEPARATOR ||
@@ -212,6 +224,7 @@ test_file (const gchar *filename, GString *string)
               g_string_append (s2, " ");
               g_string_append (s3, " ");
               g_string_append (s4, " ");
+              g_string_append (s5, " ");
             }
           else
             {
@@ -221,6 +234,7 @@ test_file (const gchar *filename, GString *string)
               g_string_append_printf (s2, "%*s", (int)strlen (str), "");
               g_string_append_printf (s3, "%*s", (int)strlen (str), "");
               g_string_append_printf (s4, "%*s", (int)strlen (str), "");
+              g_string_append_printf (s5, "%*s", (int)strlen (str), "");
               g_free (str);
             }
         }
@@ -234,11 +248,14 @@ test_file (const gchar *filename, GString *string)
   g_string_append (string, "\n");
   g_string_append_len (string, s4->str, s4->len);
   g_string_append (string, "\n");
+  g_string_append_len (string, s5->str, s5->len);
+  g_string_append (string, "\n");
 
   g_string_free (s1, TRUE);
   g_string_free (s2, TRUE);
   g_string_free (s3, TRUE);
   g_string_free (s4, TRUE);
+  g_string_free (s5, TRUE);
 
   g_object_unref (layout);
   g_free (attrs);
@@ -341,8 +358,8 @@ main (int argc, char *argv[])
       if (strcmp (argv[1], "--legend") == 0)
         {
           g_print ("test-break uses the following symbols for log attrs\n\n");
-          g_print ("Breaks:                 Words:\n"
-                   " L - mandatory break     b - word boundary\n"
+          g_print ("Breaks:                 Words:                  Graphemes:\n"
+                   " L - mandatory break     b - word boundary       b - grapheme boundary\n"
                    " l - line break          s - word start\n"
                    " c - char break          e - word end\n"
                    "\n"


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