[pango/item-offset: 3/4] test-itemize: Print more information
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/item-offset: 3/4] test-itemize: Print more information
- Date: Sat, 28 Aug 2021 16:55:27 +0000 (UTC)
commit 3f8f21293fe6ffa8709b0ff206beda78f1719eae
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 28 11:13:37 2021 -0400
test-itemize: Print more information
Print out the items num_chars and char_offset, so we
can check that the char_offset implementation works.
Update affected test outputs.
tests/itemize/one.expected | 1 +
tests/itemize/two.expected | 1 +
tests/test-itemize.c | 18 +++++++++++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/tests/itemize/one.expected b/tests/itemize/one.expected
index deaa544d..aacf60d1 100644
--- a/tests/itemize/one.expected
+++ b/tests/itemize/one.expected
@@ -1,6 +1,7 @@
<span font="Cantarell 11" fallback="false">a b
c</span>
Items: a b |[0x2028] |c
+Chars: 3(0) |1(3) |1(4)
Font: Cantarell 11 |Cantarell 11 |Cantarell 11
Script: latin |latin |latin
Lang: en-us |en-us |en-us
diff --git a/tests/itemize/two.expected b/tests/itemize/two.expected
index ebe9757c..06518c88 100644
--- a/tests/itemize/two.expected
+++ b/tests/itemize/two.expected
@@ -1,6 +1,7 @@
<span font="Cantarell 11">one <span font_features="tnum=0">tw<u>o</u> <span
font_features="dlig=1">two</span> </span>th<b>r</b>ee</span>
Items: one tw |o | two th
|r |ee
+Chars: 6(0) |1(6) |7(7)
|1(14) |2(15)
Font: Cantarell 11 |Cantarell 11 |Cantarell 11
|Cantarell Bold 11|Cantarell 11
Script: latin |latin |latin
|latin |latin
Lang: en-us |en-us |en-us
|en-us |en-us
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 921a1fdc..00af2256 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -31,6 +31,8 @@
#include <pango/pangocairo.h>
#include "test-common.h"
+#include "pango/pango-item-private.h"
+
static PangoContext *context;
@@ -104,13 +106,22 @@ apply_attributes_to_items (GList *items,
pango_attr_iterator_destroy (iter);
}
+static int
+get_item_char_offset (PangoItem *item)
+{
+ if (item->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET)
+ return ((PangoItemPrivate *)item)->char_offset;
+
+ return -1;
+}
+
static void
test_file (const gchar *filename, GString *string)
{
gchar *contents;
gsize length;
GError *error = NULL;
- GString *s1, *s2, *s3, *s4, *s5, *s6;
+ GString *s1, *s2, *s3, *s4, *s5, *s6, *s7;
char *test;
char *text;
PangoAttrList *attrs;
@@ -136,6 +147,7 @@ test_file (const gchar *filename, GString *string)
s4 = g_string_new ("Lang: ");
s5 = g_string_new ("Bidi: ");
s6 = g_string_new ("Attrs: ");
+ s7 = g_string_new ("Chars: ");
length = strlen (text);
if (text[length - 1] == '\n')
@@ -168,6 +180,7 @@ test_file (const gchar *filename, GString *string)
g_string_append_printf (s4, "%s%s", sep, pango_language_to_string (item->analysis.language));
g_string_append_printf (s5, "%s%d", sep, item->analysis.level);
g_string_append_printf (s6, "%s", sep);
+ g_string_append_printf (s7, "%s%d(%d)", sep, item->num_chars, get_item_char_offset (item));
for (a = item->analysis.extra_attrs; a; a = a->next)
{
PangoAttribute *attr = a->data;
@@ -189,10 +202,12 @@ test_file (const gchar *filename, GString *string)
g_string_append_printf (s4, "%*s", (int)(m - s4->len), "");
g_string_append_printf (s5, "%*s", (int)(m - s5->len), "");
g_string_append_printf (s6, "%*s", (int)(m - s6->len), "");
+ g_string_append_printf (s7, "%*s", (int)(m - s7->len), "");
}
g_string_append_printf (string, "%s\n", test);
g_string_append_printf (string, "%s\n", s1->str);
+ g_string_append_printf (string, "%s\n", s7->str);
g_string_append_printf (string, "%s\n", s2->str);
g_string_append_printf (string, "%s\n", s3->str);
g_string_append_printf (string, "%s\n", s4->str);
@@ -205,6 +220,7 @@ test_file (const gchar *filename, GString *string)
g_string_free (s4, TRUE);
g_string_free (s5, TRUE);
g_string_free (s6, TRUE);
+ g_string_free (s7, TRUE);
g_list_free_full (items, (GDestroyNotify)pango_item_free);
pango_attr_list_unref (attrs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]