summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-05-09 15:31:21 +0100
committerDaniel Stone <daniel@fooishbar.org>2013-05-09 15:31:21 +0100
commitb06de3072b46a5108878b8e00f934f01fdb6a0ff (patch)
treefc173b401d3b31731abdddc211e3540f00a58792 /test
parent17a956d80781846903c90b7bd4beaf8ac7aac40c (diff)
Add keycode min/max and iteration API
Add three new pieces of API: - xkb_keymap_min_keycode does what it says on the tin - xkb_keymap_max_keycode likewise - xkb_keymap_key_for_each calls the provided function once for every valid key in the keymap Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'test')
-rw-r--r--test/state.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/state.c b/test/state.c
index 34da201..3521d66 100644
--- a/test/state.c
+++ b/test/state.c
@@ -331,6 +331,28 @@ test_consume(struct xkb_keymap *keymap)
xkb_state_unref(state);
}
+static void
+key_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data)
+{
+ int *counter = (int *) data;
+
+ assert(*counter == key);
+ (*counter)++;
+}
+
+static void
+test_range(struct xkb_keymap *keymap)
+{
+ int counter;
+
+ assert(xkb_keymap_min_keycode(keymap) == 9);
+ assert(xkb_keymap_max_keycode(keymap) == 253);
+
+ counter = xkb_keymap_min_keycode(keymap);
+ xkb_keymap_key_for_each(keymap, key_iter, &counter);
+ assert(counter == xkb_keymap_max_keycode(keymap) + 1);
+}
+
int
main(void)
{
@@ -351,6 +373,7 @@ main(void)
test_serialisation(keymap);
test_repeat(keymap);
test_consume(keymap);
+ test_range(keymap);
xkb_keymap_unref(keymap);
xkb_context_unref(context);