summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2021-05-22 20:07:06 +0300
committerRan Benita <ran@unusedvar.com>2021-05-22 20:07:06 +0300
commit98f07da8952a65aae7974965bee9a2418d71efea (patch)
treec1be03e5285e900748f7db45c4baba74c3330937
parent5b1b2f754650cd2e6f87b928b92a7ca9442955b0 (diff)
downloadlibxkbcommon-98f07da8952a65aae7974965bee9a2418d71efea.tar.gz
libxkbcommon-98f07da8952a65aae7974965bee9a2418d71efea.tar.bz2
libxkbcommon-98f07da8952a65aae7974965bee9a2418d71efea.zip
test/compose: add tests for xkb_compose_table_new_from_locale lookup
Signed-off-by: Ran Benita <ran@unusedvar.com>
-rw-r--r--test/compose.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/compose.c b/test/compose.c
index a64b8cf..35790a3 100644
--- a/test/compose.c
+++ b/test/compose.c
@@ -429,6 +429,49 @@ test_XCOMPOSEFILE(struct xkb_context *ctx)
}
static void
+test_from_locale(struct xkb_context *ctx)
+{
+ struct xkb_compose_table *table;
+ char *path;
+
+ path = test_get_path("locale");
+ setenv("XLOCALEDIR", path, 1);
+ free(path);
+
+ /* Direct directory name match. */
+ table = xkb_compose_table_new_from_locale(ctx, "en_US.UTF-8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Direct locale name match. */
+ table = xkb_compose_table_new_from_locale(ctx, "C.UTF-8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Alias. */
+ table = xkb_compose_table_new_from_locale(ctx, "univ.utf8",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Special case - C. */
+ table = xkb_compose_table_new_from_locale(ctx, "C",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(table);
+ xkb_compose_table_unref(table);
+
+ /* Bogus - not found. */
+ table = xkb_compose_table_new_from_locale(ctx, "blabla",
+ XKB_COMPOSE_COMPILE_NO_FLAGS);
+ assert(!table);
+
+ unsetenv("XLOCALEDIR");
+}
+
+
+static void
test_modifier_syntax(struct xkb_context *ctx)
{
const char *table_string;
@@ -528,6 +571,7 @@ main(int argc, char *argv[])
test_seqs(ctx);
test_conflicting(ctx);
test_XCOMPOSEFILE(ctx);
+ test_from_locale(ctx);
test_state(ctx);
test_modifier_syntax(ctx);
test_include(ctx);