summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/testiter.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/testiter.c b/tests/testiter.c
index 4e70ce49..1d8069b6 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -233,6 +233,57 @@ test_layout_iter (void)
}
g_object_unref (layout);
+ g_object_unref (context);
+}
+
+static void
+test_glyphitem_iter (void)
+{
+ PangoFontMap *fontmap;
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoLayoutLine *line;
+ const char *text;
+ GSList *l;
+
+ fontmap = pango_cairo_font_map_get_default ();
+ context = pango_font_map_create_context (fontmap);
+
+ layout = pango_layout_new (context);
+ /* This shouldn't form any ligatures. */
+ pango_layout_set_text (layout, "test تست", -1);
+ text = pango_layout_get_text (layout);
+
+ line = pango_layout_get_line (layout, 0);
+ for (l = line->runs; l; l = l->next)
+ {
+ PangoGlyphItem *run = l->data;
+ int direction;
+
+ for (direction = 0; direction < 2; direction++)
+ {
+ PangoGlyphItemIter iter;
+ gboolean have_cluster;
+
+
+ for (have_cluster = direction ?
+ pango_glyph_item_iter_init_start (&iter, run, text) :
+ pango_glyph_item_iter_init_end (&iter, run, text);
+ have_cluster;
+ have_cluster = direction ?
+ pango_glyph_item_iter_next_cluster (&iter) :
+ pango_glyph_item_iter_prev_cluster (&iter))
+ {
+ verbose ("start index %d end index %d\n", iter.start_index, iter.end_index);
+ g_assert (iter.start_index < iter.end_index);
+ g_assert (iter.start_index + 2 >= iter.end_index);
+ g_assert (iter.start_char + 1 == iter.end_char);
+ }
+ }
+ }
+
+ g_object_unref (layout);
+ g_object_unref (context);
}
int
@@ -241,6 +292,7 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/layout/iter", test_layout_iter);
+ g_test_add_func ("/layout/iter", test_glyphitem_iter);
return g_test_run ();
}