[pango/italic-correction: 14/16] Add a test for pango_reorder_items
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/italic-correction: 14/16] Add a test for pango_reorder_items
- Date: Thu, 10 Mar 2022 18:53:49 +0000 (UTC)
commit 85512179c6d361dfe87e8434dc1411eba0fa6974
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Mar 1 08:15:47 2022 -0700
Add a test for pango_reorder_items
tests/testmisc.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 1aa90948..eb42b813 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -818,6 +818,43 @@ test_small_caps_crash (void)
g_object_unref (context);
}
+static void
+test_reorder (void)
+{
+ struct {
+ const char *text;
+ int offsets[10];
+ } tests[] = {
+ { "abאב01αβ", { 0, 6, 2, 8, 0, } },
+ { "abאב01גαβcd", { 0, 8, 6, 2, 10, 14 } },
+ { "abאב01גαβא", { 0, 8, 6, 2, 10, 14 } },
+ };
+ PangoContext *context;
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+
+ for (int i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+ GList *items;
+ GList *l;
+ int j;
+
+ items = pango_itemize (context, tests[i].text, 0, strlen (tests[i].text), NULL, NULL);
+
+ items = pango_reorder_items (items);
+
+ for (l = items, j = 0; l; l = l->next, j++)
+ {
+ PangoItem *item = l->data;
+ g_assert_cmpint (item->offset, ==, tests[i].offsets[j]);
+ }
+
+ g_list_free_full (items, (GDestroyNotify)pango_item_free);
+ }
+
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -853,6 +890,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/wrap-char", test_wrap_char);
g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
g_test_add_func ("/itemize/small-caps-crash", test_small_caps_crash);
+ g_test_add_func ("/itemize/reorder", test_reorder);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]