summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-10-09 20:48:35 +0200
committerRan Benita <ran234@gmail.com>2012-10-09 21:39:16 +0200
commit9179fed76bd46eb1edcb3edd0c9c515f5a7e2b31 (patch)
treee0d8307a7cf37cafd1404e6f898936b47658c740 /test
parent2ac319c54ab2072709916cced2e0eb8c8d37f859 (diff)
keysym: fix xkb_keysym_is_upper/lower() to work properly
Our current code (taken from the xserver) doesn't handle unicode keysyms at all, and there seem to be some other changes compared to libX11, which is what xkbcomp uses. So we just copy the code that does that from libX11. It would be much better to not have to hardcode unicode tables like that, but it's probably better than dealing with glibc locale stuff for now. It also doesn't affect our binary size much. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/keysym.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/keysym.c b/test/keysym.c
index 1bf704b..ef934ab 100644
--- a/test/keysym.c
+++ b/test/keysym.c
@@ -22,6 +22,7 @@
*/
#include "test.h"
+#include "keysym.h" /* For unexported is_lower/upper/keypad() */
static int
test_string(const char *string, xkb_keysym_t expected)
@@ -97,5 +98,33 @@ main(void)
assert(test_utf8(XKB_KEY_KP_Multiply, "*"));
assert(test_utf8(XKB_KEY_KP_Subtract, "-"));
+ assert(xkb_keysym_is_lower(XKB_KEY_a));
+ assert(xkb_keysym_is_lower(XKB_KEY_Greek_lambda));
+ assert(xkb_keysym_is_lower(xkb_keysym_from_name("U03b1"))); /* GREEK SMALL LETTER ALPHA */
+ assert(xkb_keysym_is_lower(xkb_keysym_from_name("U03af"))); /* GREEK SMALL LETTER IOTA WITH TONOS */
+
+ assert(xkb_keysym_is_upper(XKB_KEY_A));
+ assert(xkb_keysym_is_upper(XKB_KEY_Greek_LAMBDA));
+ assert(xkb_keysym_is_upper(xkb_keysym_from_name("U0391"))); /* GREEK CAPITAL LETTER ALPHA */
+ assert(xkb_keysym_is_upper(xkb_keysym_from_name("U0388"))); /* GREEK CAPITAL LETTER EPSILON WITH TONOS */
+
+ assert(!xkb_keysym_is_upper(XKB_KEY_a));
+ assert(!xkb_keysym_is_lower(XKB_KEY_A));
+ assert(!xkb_keysym_is_lower(XKB_KEY_Return));
+ assert(!xkb_keysym_is_upper(XKB_KEY_Return));
+ assert(!xkb_keysym_is_lower(XKB_KEY_hebrew_aleph));
+ assert(!xkb_keysym_is_upper(XKB_KEY_hebrew_aleph));
+ assert(!xkb_keysym_is_upper(xkb_keysym_from_name("U05D0"))); /* HEBREW LETTER ALEF */
+ assert(!xkb_keysym_is_lower(xkb_keysym_from_name("U05D0"))); /* HEBREW LETTER ALEF */
+ assert(!xkb_keysym_is_lower(XKB_KEY_8));
+ assert(!xkb_keysym_is_upper(XKB_KEY_8));
+
+ assert(xkb_keysym_is_keypad(XKB_KEY_KP_Enter));
+ assert(xkb_keysym_is_keypad(XKB_KEY_KP_6));
+ assert(xkb_keysym_is_keypad(XKB_KEY_KP_Add));
+ assert(!xkb_keysym_is_keypad(XKB_KEY_Num_Lock));
+ assert(!xkb_keysym_is_keypad(XKB_KEY_1));
+ assert(!xkb_keysym_is_keypad(XKB_KEY_Return));
+
return 0;
}