2021-02-01 20:48:06 +00:00
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
|
2021-02-01 20:48:06 +00:00
|
|
|
|
#include "../gtk/gtkcomposetable.h"
|
2021-02-02 02:10:44 +00:00
|
|
|
|
#include "../gtk/gtkimcontextsimpleseqs.h"
|
2021-02-01 20:48:06 +00:00
|
|
|
|
#include "testsuite/testutils.h"
|
|
|
|
|
|
2021-02-02 16:53:24 +00:00
|
|
|
|
static void
|
|
|
|
|
append_escaped (GString *str,
|
|
|
|
|
const char *s)
|
|
|
|
|
{
|
|
|
|
|
for (const char *p = s; *p; p = g_utf8_next_char (p))
|
|
|
|
|
{
|
|
|
|
|
gunichar ch = g_utf8_get_char (p);
|
|
|
|
|
if (ch == '"')
|
|
|
|
|
g_string_append (str, "\\\"");
|
|
|
|
|
else if (ch == '\\')
|
|
|
|
|
g_string_append (str, "\\\\");
|
|
|
|
|
else if (g_unichar_isprint (ch))
|
|
|
|
|
g_string_append_unichar (str, ch);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
guint n[8] = { 0, };
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (ch != 0)
|
|
|
|
|
{
|
|
|
|
|
n[i++] = ch & 7;
|
|
|
|
|
ch = ch >> 3;
|
|
|
|
|
}
|
|
|
|
|
for (; i >= 0; i--)
|
|
|
|
|
g_string_append_printf (str, "\\%o", n[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
static void
|
|
|
|
|
print_sequence (gunichar *sequence,
|
|
|
|
|
int len,
|
|
|
|
|
const char *value,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GString *str = data;
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < len; j++)
|
|
|
|
|
g_string_append_printf (str, "<U%x> ", sequence[j]);
|
|
|
|
|
|
|
|
|
|
g_string_append (str, ": \"");
|
|
|
|
|
append_escaped (str, value);
|
|
|
|
|
g_string_append (str, "\"");
|
|
|
|
|
|
|
|
|
|
if (g_utf8_strlen (value, -1) == 1)
|
|
|
|
|
{
|
|
|
|
|
gunichar ch = g_utf8_get_char (value);
|
|
|
|
|
g_string_append_printf (str, " # U%x", ch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_string_append_c (str, '\n');
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 20:48:06 +00:00
|
|
|
|
static char *
|
|
|
|
|
gtk_compose_table_print (GtkComposeTable *table)
|
|
|
|
|
{
|
|
|
|
|
GString *str;
|
|
|
|
|
|
|
|
|
|
str = g_string_new ("");
|
|
|
|
|
|
2021-07-15 12:14:40 +00:00
|
|
|
|
g_string_append_printf (str, "# n_sequences: %d\n# max_seq_len: %d\n# n_index_size: %d\n# data_size: %d\n# n_chars: %d\n",
|
|
|
|
|
table->n_sequences,
|
2021-07-08 21:59:50 +00:00
|
|
|
|
table->max_seq_len,
|
|
|
|
|
table->n_index_size,
|
|
|
|
|
table->data_size,
|
|
|
|
|
table->n_chars);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
gtk_compose_table_foreach (table, print_sequence, str);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
|
|
|
|
|
return g_string_free (str, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
generate_output (const char *file)
|
|
|
|
|
{
|
|
|
|
|
GtkComposeTable *table;
|
|
|
|
|
char *output;
|
|
|
|
|
|
2021-07-14 11:38:32 +00:00
|
|
|
|
table = gtk_compose_table_parse (file, NULL);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
output = gtk_compose_table_print (table);
|
|
|
|
|
|
|
|
|
|
g_print ("%s", output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
compose_table_compare (gconstpointer data)
|
|
|
|
|
{
|
|
|
|
|
const char *basename = data;
|
|
|
|
|
GtkComposeTable *table;
|
|
|
|
|
char *file;
|
|
|
|
|
char *expected;
|
|
|
|
|
char *output;
|
|
|
|
|
char *diff;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
file = g_test_build_filename (G_TEST_DIST, "compose", basename, NULL);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
expected = g_strconcat (file, ".expected", NULL);
|
|
|
|
|
|
2021-07-14 11:38:32 +00:00
|
|
|
|
table = gtk_compose_table_parse (file, NULL);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
output = gtk_compose_table_print (table);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
|
2021-02-01 20:48:06 +00:00
|
|
|
|
diff = diff_with_file (expected, output, -1, &error);
|
|
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
|
|
if (diff && diff[0])
|
|
|
|
|
{
|
|
|
|
|
g_print ("Resulting output doesn't match reference:\n%s", diff);
|
|
|
|
|
g_test_fail ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (output);
|
|
|
|
|
g_free (file);
|
|
|
|
|
g_free (expected);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-07 14:47:17 +00:00
|
|
|
|
static void
|
|
|
|
|
compose_table_cycle (void)
|
|
|
|
|
{
|
|
|
|
|
if (g_test_subprocess ())
|
|
|
|
|
{
|
|
|
|
|
char *file;
|
|
|
|
|
GtkComposeTable *table;
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
file = g_test_build_filename (G_TEST_DIST, "compose", "cycle", NULL);
|
2021-07-07 14:47:17 +00:00
|
|
|
|
|
2021-07-14 11:38:32 +00:00
|
|
|
|
table = gtk_compose_table_parse (file, NULL);
|
2021-07-07 14:47:17 +00:00
|
|
|
|
g_assert_nonnull (table);
|
|
|
|
|
g_free (file);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_test_trap_subprocess (NULL, 0, 0);
|
|
|
|
|
g_test_trap_assert_stderr ("*include cycle detected*");
|
|
|
|
|
g_test_trap_assert_failed ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
compose_table_nofile (void)
|
|
|
|
|
{
|
|
|
|
|
if (g_test_subprocess ())
|
|
|
|
|
{
|
|
|
|
|
char *file;
|
|
|
|
|
GtkComposeTable *table;
|
|
|
|
|
|
|
|
|
|
file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose", "nofile", NULL);
|
|
|
|
|
|
2021-07-14 11:38:32 +00:00
|
|
|
|
table = gtk_compose_table_parse (file, NULL);
|
2021-07-07 14:47:17 +00:00
|
|
|
|
g_assert_nonnull (table);
|
|
|
|
|
g_free (file);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_test_trap_subprocess (NULL, 0, 0);
|
|
|
|
|
g_test_trap_assert_stderr ("*No such file or directory*");
|
|
|
|
|
g_test_trap_assert_failed ();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 02:10:44 +00:00
|
|
|
|
/* Check matching against a small table */
|
2021-02-02 00:55:56 +00:00
|
|
|
|
static void
|
|
|
|
|
compose_table_match (void)
|
|
|
|
|
{
|
|
|
|
|
GtkComposeTable *table;
|
|
|
|
|
char *file;
|
2021-08-02 23:15:16 +00:00
|
|
|
|
guint buffer[8] = { 0, };
|
2021-02-02 00:55:56 +00:00
|
|
|
|
gboolean finish, match, ret;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
GString *output;
|
|
|
|
|
|
|
|
|
|
output = g_string_new ("");
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose", "match", NULL);
|
|
|
|
|
|
2021-07-14 11:38:32 +00:00
|
|
|
|
table = gtk_compose_table_parse (file, NULL);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = 0;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 1, &finish, &match, output);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_false (match);
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_assert_true (output->len == 0);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_a;
|
|
|
|
|
buffer[1] = 0;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 1, &finish, &match, output);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_assert_false (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_false (match);
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_assert_true (output->len == 0);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = GDK_KEY_s;
|
|
|
|
|
buffer[2] = GDK_KEY_e;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 3, &finish, &match, output);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_false (match);
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_assert_true (output->len == 0);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = GDK_KEY_s;
|
|
|
|
|
buffer[2] = GDK_KEY_e;
|
|
|
|
|
buffer[3] = GDK_KEY_q;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 4, &finish, &match, output);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_true (match);
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "!");
|
|
|
|
|
|
|
|
|
|
g_string_set_size (output, 0);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = GDK_KEY_s;
|
|
|
|
|
buffer[2] = GDK_KEY_e;
|
|
|
|
|
buffer[3] = GDK_KEY_q;
|
|
|
|
|
buffer[4] = GDK_KEY_u;
|
2021-02-02 04:37:05 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 5, &finish, &match, output);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_true (finish);
|
|
|
|
|
g_assert_true (match);
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "?");
|
2021-02-02 00:55:56 +00:00
|
|
|
|
|
2021-09-21 14:56:47 +00:00
|
|
|
|
g_string_set_size (output, 0);
|
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = GDK_KEY_l;
|
|
|
|
|
buffer[2] = GDK_KEY_o;
|
|
|
|
|
buffer[3] = GDK_KEY_n;
|
|
|
|
|
buffer[4] = GDK_KEY_g;
|
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 5, &finish, &match, output);
|
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_true (finish);
|
|
|
|
|
g_assert_true (match);
|
|
|
|
|
g_assert_cmpstr (output->str, ==, "this is a long replacement string");
|
|
|
|
|
|
2021-02-02 04:37:05 +00:00
|
|
|
|
g_string_free (output, TRUE);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_free (file);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
extern const GtkComposeTable builtin_compose_table;
|
|
|
|
|
|
2021-02-02 02:10:44 +00:00
|
|
|
|
/* just check some random sequences */
|
|
|
|
|
static void
|
2021-07-08 21:59:50 +00:00
|
|
|
|
compose_table_match_builtin (void)
|
2021-02-02 02:10:44 +00:00
|
|
|
|
{
|
2021-07-08 21:59:50 +00:00
|
|
|
|
const GtkComposeTable *table = &builtin_compose_table;
|
2021-08-02 23:15:16 +00:00
|
|
|
|
guint buffer[8] = { 0, };
|
2021-02-02 02:10:44 +00:00
|
|
|
|
gboolean finish, match, ret;
|
2021-07-08 21:59:50 +00:00
|
|
|
|
GString *s;
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
2021-04-01 19:18:20 +00:00
|
|
|
|
buffer[1] = 0;
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
s = g_string_new ("");
|
|
|
|
|
|
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 1, &finish, &match, s);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_false (match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_assert_true (s->len == 0);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_a;
|
|
|
|
|
buffer[1] = GDK_KEY_b;
|
|
|
|
|
buffer[2] = GDK_KEY_c;
|
2021-04-01 19:18:20 +00:00
|
|
|
|
buffer[3] = 0;
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 3, &finish, &match, s);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
g_assert_false (ret);
|
|
|
|
|
g_assert_false (finish);
|
|
|
|
|
g_assert_false (match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_assert_true (s->len == 0);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_Multi_key;
|
|
|
|
|
buffer[1] = GDK_KEY_parenleft;
|
|
|
|
|
buffer[2] = GDK_KEY_j;
|
|
|
|
|
buffer[3] = GDK_KEY_parenright;
|
2021-04-01 19:18:20 +00:00
|
|
|
|
buffer[4] = 0;
|
2021-02-02 02:10:44 +00:00
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 4, &finish, &match, s);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_true (finish);
|
|
|
|
|
g_assert_true (match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_assert_cmpstr (s->str, ==, "ⓙ"); /* CIRCLED LATIN SMALL LETTER J */
|
2021-04-01 19:18:20 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[1] = GDK_KEY_space;
|
|
|
|
|
buffer[2] = 0;
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_string_set_size (s, 0);
|
|
|
|
|
|
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 2, &finish, &match, s);
|
2021-04-01 19:18:20 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_true (finish);
|
|
|
|
|
g_assert_true (match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_assert_cmpstr (s->str, ==, "'");
|
2021-04-01 19:18:20 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[2] = 0;
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_string_set_size (s, 0);
|
|
|
|
|
|
|
|
|
|
ret = gtk_compose_table_check (table, buffer, 2, &finish, &match, s);
|
2021-04-01 19:18:20 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_true (finish);
|
|
|
|
|
g_assert_true (match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_assert_cmpstr (s->str, ==, "´");
|
|
|
|
|
|
|
|
|
|
g_string_free (s, TRUE);
|
2021-02-02 02:10:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-02 02:52:42 +00:00
|
|
|
|
static void
|
|
|
|
|
match_algorithmic (void)
|
|
|
|
|
{
|
2021-08-02 23:15:16 +00:00
|
|
|
|
guint buffer[8] = { 0, };
|
2021-02-02 02:52:42 +00:00
|
|
|
|
gboolean ret;
|
2021-07-29 19:47:04 +00:00
|
|
|
|
GString *output;
|
|
|
|
|
|
|
|
|
|
output = g_string_new ("");
|
2021-02-02 02:52:42 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_a;
|
|
|
|
|
buffer[1] = GDK_KEY_b;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_assert_false (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "");
|
2021-02-02 02:52:42 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_abovering;
|
|
|
|
|
buffer[1] = GDK_KEY_A;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "Å");
|
2021-02-02 02:52:42 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_A;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_abovering;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_assert_false (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "");
|
2021-02-02 02:52:42 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_dasia;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_perispomeni;
|
|
|
|
|
buffer[2] = GDK_KEY_Greek_alpha;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 3, output);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 20:36:25 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "ᾶ\xcc\x94");
|
2021-02-02 02:52:42 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_perispomeni;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_dasia;
|
|
|
|
|
buffer[2] = GDK_KEY_Greek_alpha;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 3, output);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "ἇ");
|
2021-03-27 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_cedilla;
|
|
|
|
|
buffer[2] = GDK_KEY_c;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-03-27 00:14:24 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "");
|
2021-03-27 00:14:24 +00:00
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 3, output);
|
2021-03-27 00:14:24 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "ḉ");
|
2021-03-27 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_cedilla;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[2] = GDK_KEY_c;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 3, output);
|
2021-03-27 00:14:24 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "ḉ");
|
2021-03-27 00:14:24 +00:00
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-04-01 20:32:30 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
|
2021-03-27 00:14:24 +00:00
|
|
|
|
buffer[0] = GDK_KEY_dead_acute;
|
|
|
|
|
buffer[1] = GDK_KEY_dead_cedilla;
|
|
|
|
|
buffer[2] = GDK_KEY_dead_grave;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 3, output);
|
2021-07-29 20:36:25 +00:00
|
|
|
|
g_assert_true (ret);
|
|
|
|
|
g_assert_cmpstr (output->str, ==, "");
|
2021-04-01 20:32:30 +00:00
|
|
|
|
|
|
|
|
|
buffer[0] = GDK_KEY_dead_diaeresis;
|
|
|
|
|
buffer[1] = GDK_KEY_a;
|
|
|
|
|
|
2021-07-29 19:47:04 +00:00
|
|
|
|
ret = gtk_check_algorithmically (buffer, 2, output);
|
2021-04-01 20:32:30 +00:00
|
|
|
|
g_assert_true (ret);
|
2021-07-29 19:47:04 +00:00
|
|
|
|
g_assert_cmpstr (output->str, ==, "ä");
|
|
|
|
|
|
|
|
|
|
g_string_free (output, TRUE);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 20:48:06 +00:00
|
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
if (argc == 3 && strcmp (argv[1], "--generate") == 0)
|
|
|
|
|
{
|
2021-07-08 21:59:50 +00:00
|
|
|
|
gtk_disable_setlocale();
|
|
|
|
|
setlocale (LC_ALL, "en_US.UTF-8");
|
|
|
|
|
|
|
|
|
|
gtk_init ();
|
|
|
|
|
|
|
|
|
|
/* Ensure that the builtin table is initialized */
|
|
|
|
|
GtkIMContext *ctx = gtk_im_context_simple_new ();
|
|
|
|
|
g_object_unref (ctx);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
|
|
|
|
|
generate_output (argv[2]);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_test_init (&argc, &argv, NULL);
|
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
|
/* Ensure that the builtin table is initialized */
|
|
|
|
|
GtkIMContext *ctx = gtk_im_context_simple_new ();
|
|
|
|
|
g_object_unref (ctx);
|
|
|
|
|
|
2021-02-01 20:48:06 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/basic", "basic", compose_table_compare);
|
|
|
|
|
g_test_add_data_func ("/compose-table/long", "long", compose_table_compare);
|
|
|
|
|
g_test_add_data_func ("/compose-table/octal", "octal", compose_table_compare);
|
2021-02-02 17:00:51 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/hex", "hex", compose_table_compare);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/codepoint", "codepoint", compose_table_compare);
|
|
|
|
|
g_test_add_data_func ("/compose-table/multi", "multi", compose_table_compare);
|
2021-02-02 16:53:24 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/strings", "strings", compose_table_compare);
|
2022-09-13 02:21:39 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/single", "single", compose_table_compare);
|
2021-07-07 14:47:17 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/include", "include", compose_table_compare);
|
2021-07-07 17:56:19 +00:00
|
|
|
|
g_test_add_data_func ("/compose-table/system", "system", compose_table_compare);
|
2021-07-07 14:47:17 +00:00
|
|
|
|
g_test_add_func ("/compose-table/include-cycle", compose_table_cycle);
|
|
|
|
|
g_test_add_func ("/compose-table/include-nofile", compose_table_nofile);
|
2021-02-02 00:55:56 +00:00
|
|
|
|
g_test_add_func ("/compose-table/match", compose_table_match);
|
2021-07-08 21:59:50 +00:00
|
|
|
|
g_test_add_func ("/compose-table/match-builtin", compose_table_match_builtin);
|
2021-02-02 02:52:42 +00:00
|
|
|
|
g_test_add_func ("/compose-table/match-algorithmic", match_algorithmic);
|
2021-02-01 20:48:06 +00:00
|
|
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
|
}
|