[gtk/im-context-work] Add tests for GtkComposeTable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/im-context-work] Add tests for GtkComposeTable
- Date: Mon, 1 Feb 2021 21:05:37 +0000 (UTC)
commit d72bce86433a7917d0d5b2576e64955019aa57b2
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 1 15:48:06 2021 -0500
Add tests for GtkComposeTable
Add some tests for the code that parses Compose files.
This tests the fix in the previous commit.
testsuite/gtk/compose/basic | 1 +
testsuite/gtk/compose/codepoint | 1 +
testsuite/gtk/compose/long | 1 +
testsuite/gtk/compose/octal | 1 +
testsuite/gtk/composetable.c | 135 ++++++++++++++++++++++++++++++++++++++++
testsuite/gtk/meson.build | 1 +
6 files changed, 140 insertions(+)
---
diff --git a/testsuite/gtk/compose/basic b/testsuite/gtk/compose/basic
new file mode 100644
index 0000000000..536fb013fc
--- /dev/null
+++ b/testsuite/gtk/compose/basic
@@ -0,0 +1 @@
+<Multi_key> <s> <e> <q> : "!"
diff --git a/testsuite/gtk/compose/codepoint b/testsuite/gtk/compose/codepoint
new file mode 100644
index 0000000000..22f44be8f9
--- /dev/null
+++ b/testsuite/gtk/compose/codepoint
@@ -0,0 +1 @@
+<Multi_key> <U73> <U6F> <U7a> : "!"
diff --git a/testsuite/gtk/compose/long b/testsuite/gtk/compose/long
new file mode 100644
index 0000000000..84ef7acee8
--- /dev/null
+++ b/testsuite/gtk/compose/long
@@ -0,0 +1 @@
+<Multi_key> <e> <m> <m> <e> <n> <t> <a> <l> <e> <r> : "🧀"
diff --git a/testsuite/gtk/compose/octal b/testsuite/gtk/compose/octal
new file mode 100644
index 0000000000..350ecf8951
--- /dev/null
+++ b/testsuite/gtk/compose/octal
@@ -0,0 +1 @@
+<Multi_key> <s> <e> <q> : "\041"
diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c
new file mode 100644
index 0000000000..3c97155230
--- /dev/null
+++ b/testsuite/gtk/composetable.c
@@ -0,0 +1,135 @@
+#include <gtk/gtk.h>
+
+#include "../gtk/gtkcomposetable.h"
+
+static void
+compose_table_basic (void)
+{
+ GSList *tables = NULL;
+ GtkComposeTable *table;
+ char *file;
+
+ file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose/basic", NULL);
+
+ tables = gtk_compose_table_list_add_file (tables, file);
+
+ g_assert_true (g_slist_length (tables) == 1);
+
+ table = tables->data;
+
+ g_assert_true (table->n_seqs == 1);
+ g_assert_true (table->max_seq_len == 4);
+
+ g_assert_true (table->data[0] == GDK_KEY_Multi_key);
+ g_assert_true (table->data[1] == GDK_KEY_s);
+ g_assert_true (table->data[2] == GDK_KEY_e);
+ g_assert_true (table->data[3] == GDK_KEY_q);
+ g_assert_true (table->data[4] == 0);
+ g_assert_true (table->data[5] == '!');
+
+ g_free (file);
+}
+
+static void
+compose_table_long (void)
+{
+ GSList *tables = NULL;
+ GtkComposeTable *table;
+ char *file;
+
+ file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose/long", NULL);
+
+ tables = gtk_compose_table_list_add_file (tables, file);
+
+ g_assert_true (g_slist_length (tables) == 1);
+
+ table = tables->data;
+
+ g_assert_true (table->n_seqs == 1);
+ g_assert_true (table->max_seq_len == 11);
+
+ g_assert_true (table->data[0] == GDK_KEY_Multi_key);
+ g_assert_true (table->data[1] == GDK_KEY_e);
+ g_assert_true (table->data[2] == GDK_KEY_m);
+ g_assert_true (table->data[3] == GDK_KEY_m);
+ g_assert_true (table->data[4] == GDK_KEY_e);
+ g_assert_true (table->data[5] == GDK_KEY_n);
+ g_assert_true (table->data[6] == GDK_KEY_t);
+ g_assert_true (table->data[7] == GDK_KEY_a);
+ g_assert_true (table->data[8] == GDK_KEY_l);
+ g_assert_true (table->data[9] == GDK_KEY_e);
+ g_assert_true (table->data[10] == GDK_KEY_r);
+ g_assert_true (table->data[11] == 0x1);
+ g_assert_true (table->data[12] == 0xf9c0);
+
+ g_free (file);
+}
+
+static void
+compose_table_octal (void)
+{
+ GSList *tables = NULL;
+ GtkComposeTable *table;
+ char *file;
+
+ file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose/octal", NULL);
+
+ tables = gtk_compose_table_list_add_file (tables, file);
+
+ g_assert_true (g_slist_length (tables) == 1);
+
+ table = tables->data;
+
+ g_assert_true (table->n_seqs == 1);
+ g_assert_true (table->max_seq_len == 4);
+
+ g_assert_true (table->data[0] == GDK_KEY_Multi_key);
+ g_assert_true (table->data[1] == GDK_KEY_s);
+ g_assert_true (table->data[2] == GDK_KEY_e);
+ g_assert_true (table->data[3] == GDK_KEY_q);
+ g_assert_true (table->data[4] == 0);
+ g_assert_true (table->data[5] == '!');
+
+ g_free (file);
+}
+
+static void
+compose_table_codepoint (void)
+{
+ GSList *tables = NULL;
+ GtkComposeTable *table;
+ char *file;
+
+ file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose/codepoint", NULL);
+
+ tables = gtk_compose_table_list_add_file (tables, file);
+
+ g_assert_true (g_slist_length (tables) == 1);
+
+ table = tables->data;
+
+ g_assert_true (table->n_seqs == 1);
+ g_assert_true (table->max_seq_len == 4);
+
+ g_assert_true (table->data[0] == GDK_KEY_Multi_key);
+ g_assert_true (table->data[1] == GDK_KEY_s);
+ g_assert_true (table->data[2] == GDK_KEY_o);
+ g_assert_true (table->data[3] == GDK_KEY_z);
+ g_assert_true (table->data[4] == 0);
+ g_assert_true (table->data[5] == '!');
+
+ g_free (file);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/compose-table/basic", compose_table_basic);
+ g_test_add_func ("/compose-table/long", compose_table_long);
+ g_test_add_func ("/compose-table/octal", compose_table_octal);
+ g_test_add_func ("/compose-table/codepoint", compose_table_codepoint);
+
+ return g_test_run ();
+}
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index 1ba0bfd9d8..d0dc8fc6ab 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -103,6 +103,7 @@ tests = [
# Tests that test private apis and therefore are linked against libgtk-4.a
internal_tests = [
{ 'name': 'bitmask' },
+ { 'name': 'composetable' },
{ 'name': 'constraint-solver' },
{ 'name': 'rbtree-crash' },
{ 'name': 'propertylookuplistmodel' },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]