summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-03-01 21:48:02 +0200
committerDaniel Stone <daniel@fooishbar.org>2013-03-18 22:20:04 +0000
commit14842d6dc911db0a30afff8c75a89d34390de2e9 (patch)
tree3c7f9c19241564107db14e6251c49aa5d0d32401 /test
parentd1eae42ac58a334c5d299ef66342957deae4cd78 (diff)
keymap: abstract a bit over the keymap format
Make it a bit easier to experiment with other formats. Add a struct xkb_keymap_format_operations, which currently contains the keymap compilation and _get_as_string functions. Each format can implement whatever it wants from these. The current public entry points become wrappers which do some error reporting, allocation etc., and calling to the specific format. The wrappers are all moved to src/keymap.c, so there are no XKB_EXPORT's under src/xkbcomp/ anymore. The only format available now is normal text_v1. This is all not very KISS, and adds some indirection, but it is helpful and somewhat cleaner. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/filecomp.c9
-rw-r--r--test/rulescomp.c7
-rw-r--r--test/stringcomp.c10
3 files changed, 26 insertions, 0 deletions
diff --git a/test/filecomp.c b/test/filecomp.c
index 0c1111a..eafe568 100644
--- a/test/filecomp.c
+++ b/test/filecomp.c
@@ -48,6 +48,15 @@ main(void)
assert(!test_file(ctx, "keymaps/bad.xkb"));
assert(!test_file(ctx, "does not exist"));
+ /* Test response to invalid flags and formats. */
+ fclose(stdin);
+ assert(!xkb_keymap_new_from_file(ctx, NULL, XKB_KEYMAP_FORMAT_TEXT_V1, 0));
+ assert(!xkb_keymap_new_from_file(ctx, stdin, 0, 0));
+ assert(!xkb_keymap_new_from_file(ctx, stdin, XKB_KEYMAP_USE_ORIGINAL_FORMAT, 0));
+ assert(!xkb_keymap_new_from_file(ctx, stdin, 1234, 0));
+ assert(!xkb_keymap_new_from_file(ctx, stdin, XKB_KEYMAP_FORMAT_TEXT_V1, -1));
+ assert(!xkb_keymap_new_from_file(ctx, stdin, XKB_KEYMAP_FORMAT_TEXT_V1, 1234));
+
xkb_context_unref(ctx);
return 0;
diff --git a/test/rulescomp.c b/test/rulescomp.c
index 7318f75..55113f6 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -118,5 +118,12 @@ int main(int argc, char *argv[])
assert(!test_rmlvo(ctx, "does-not-exist", "", "", "", ""));
+ /* Test response to invalid flags. */
+ {
+ struct xkb_rule_names rmlvo = { NULL };
+ assert(!xkb_keymap_new_from_names(ctx, &rmlvo, -1));
+ assert(!xkb_keymap_new_from_names(ctx, &rmlvo, 5453));
+ }
+
xkb_context_unref(ctx);
}
diff --git a/test/stringcomp.c b/test/stringcomp.c
index 7d13340..ab5bbef 100644
--- a/test/stringcomp.c
+++ b/test/stringcomp.c
@@ -81,6 +81,16 @@ main(int argc, char *argv[])
xkb_keymap_unref(keymap);
keymap = test_compile_string(ctx, dump);
assert(keymap);
+
+ /* Test response to invalid formats and flags. */
+ assert(!xkb_keymap_new_from_string(ctx, dump, 0, 0));
+ assert(!xkb_keymap_new_from_string(ctx, dump, -1, 0));
+ assert(!xkb_keymap_new_from_string(ctx, dump, XKB_KEYMAP_FORMAT_TEXT_V1+1, 0));
+ assert(!xkb_keymap_new_from_string(ctx, dump, XKB_KEYMAP_FORMAT_TEXT_V1, -1));
+ assert(!xkb_keymap_new_from_string(ctx, dump, XKB_KEYMAP_FORMAT_TEXT_V1, 1414));
+ assert(!xkb_keymap_get_as_string(keymap, 0));
+ assert(!xkb_keymap_get_as_string(keymap, 4893));
+
xkb_keymap_unref(keymap);
free(dump);