[gtk/im-context-work] composetable: Add tests for compact table matching
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/im-context-work] composetable: Add tests for compact table matching
- Date: Tue, 2 Feb 2021 02:59:40 +0000 (UTC)
commit 8d18d937422a406468e3e5f0ac17125f9137d2d6
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 1 21:10:44 2021 -0500
composetable: Add tests for compact table matching
Not very exhaustive, just some spot checks.
testsuite/gtk/composetable.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
---
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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]