summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-01 21:10:44 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-01 21:10:44 -0500
commit8d18d937422a406468e3e5f0ac17125f9137d2d6 (patch)
tree7c92a598f4ee9ed5a9deef459aa0473eb0fb1d53
parent10fcdd88e3c31079f67d9bf3015466be21515a07 (diff)
downloadgtk+-8d18d937422a406468e3e5f0ac17125f9137d2d6.tar.gz
composetable: Add tests for compact table matching
Not very exhaustive, just some spot checks.
-rw-r--r--testsuite/gtk/composetable.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c
index 7c0a767e2f..c1608e1af4 100644
--- a/testsuite/gtk/composetable.c
+++ b/testsuite/gtk/composetable.c
@@ -2,6 +2,7 @@
#include <locale.h>
#include "../gtk/gtkcomposetable.h"
+#include "../gtk/gtkimcontextsimpleseqs.h"
#include "testsuite/testutils.h"
static char *
@@ -84,6 +85,7 @@ compose_table_compare (gconstpointer data)
g_free (expected);
}
+/* Check matching against a small table */
static void
compose_table_match (void)
{
@@ -151,6 +153,50 @@ compose_table_match (void)
g_free (file);
}
+/* just check some random sequences */
+static void
+compose_table_match_compact (void)
+{
+ const GtkComposeTableCompact table = {
+ gtk_compose_seqs_compact,
+ 5,
+ 30,
+ 6
+ };
+ guint16 buffer[8] = { 0, };
+ gboolean finish, match, ret;
+ gunichar ch;
+
+ buffer[0] = GDK_KEY_Multi_key;
+
+ ret = gtk_compose_table_compact_check (&table, buffer, 1, &finish, &match, &ch);
+ g_assert_true (ret);
+ g_assert_false (finish);
+ g_assert_false (match);
+ g_assert_true (ch == 0);
+
+ buffer[0] = GDK_KEY_a;
+ buffer[1] = GDK_KEY_b;
+ buffer[2] = GDK_KEY_c;
+
+ ret = gtk_compose_table_compact_check (&table, buffer, 3, &finish, &match, &ch);
+ g_assert_false (ret);
+ g_assert_false (finish);
+ g_assert_false (match);
+ g_assert_true (ch == 0);
+
+ buffer[0] = GDK_KEY_Multi_key;
+ buffer[1] = GDK_KEY_parenleft;
+ buffer[2] = GDK_KEY_j;
+ buffer[3] = GDK_KEY_parenright;
+
+ ret = gtk_compose_table_compact_check (&table, buffer, 4, &finish, &match, &ch);
+ g_assert_true (ret);
+ g_assert_true (finish);
+ g_assert_true (match);
+ g_assert_true (ch == 0x24d9); /* CIRCLED LATIN SMALL LETTER J */
+}
+
int
main (int argc, char *argv[])
{
@@ -176,6 +222,7 @@ main (int argc, char *argv[])
g_test_add_data_func ("/compose-table/codepoint", "codepoint", compose_table_compare);
g_test_add_data_func ("/compose-table/multi", "multi", compose_table_compare);
g_test_add_func ("/compose-table/match", compose_table_match);
+ g_test_add_func ("/compose-table/match-compact", compose_table_match_compact);
return g_test_run ();
}