2012-03-30 17:44:39 -06:00
|
|
|
#include <assert.h>
|
2009-01-20 19:57:22 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-30 17:44:39 -06:00
|
|
|
#include "xkbcommon/xkbcommon.h"
|
|
|
|
|
|
|
|
static int
|
|
|
|
test_string(const char *string, xkb_keysym_t expected)
|
2009-01-20 19:57:22 -07:00
|
|
|
{
|
2012-03-30 17:44:39 -06:00
|
|
|
xkb_keysym_t keysym;
|
|
|
|
|
2012-05-09 06:22:34 -06:00
|
|
|
keysym = xkb_keysym_from_name(string);
|
2012-03-30 17:44:39 -06:00
|
|
|
|
|
|
|
fprintf(stderr, "Expected string %s -> %x\n", string, expected);
|
|
|
|
fprintf(stderr, "Received string %s -> %x\n\n", string, keysym);
|
|
|
|
|
|
|
|
return keysym == expected;
|
2009-01-20 19:57:22 -07:00
|
|
|
}
|
|
|
|
|
2012-03-30 17:44:39 -06:00
|
|
|
static int
|
|
|
|
test_keysym(xkb_keysym_t keysym, const char *expected)
|
2009-01-20 19:57:22 -07:00
|
|
|
{
|
2010-10-08 13:33:18 -06:00
|
|
|
char s[16];
|
|
|
|
|
2012-05-09 06:22:34 -06:00
|
|
|
xkb_keysym_get_name(keysym, s, sizeof(s));
|
2012-03-30 17:44:39 -06:00
|
|
|
|
|
|
|
fprintf(stderr, "Expected keysym %#x -> %s\n", keysym, expected);
|
|
|
|
fprintf(stderr, "Received keysym %#x -> %s\n\n", keysym, s);
|
|
|
|
|
|
|
|
return strcmp(s, expected) == 0;
|
2009-01-20 19:57:22 -07:00
|
|
|
}
|
|
|
|
|
2012-03-30 17:44:39 -06:00
|
|
|
int
|
|
|
|
main(void)
|
2009-01-20 19:57:22 -07:00
|
|
|
{
|
2012-03-30 17:44:39 -06:00
|
|
|
assert(test_string("Undo", 0xFF65));
|
|
|
|
assert(test_string("ThisKeyShouldNotExist", XKB_KEYSYM_NO_SYMBOL));
|
|
|
|
assert(test_string("XF86_Switch_VT_5", 0x1008FE05));
|
|
|
|
assert(test_string("VoidSymbol", 0xFFFFFF));
|
|
|
|
assert(test_string("U4567", 0x1004567));
|
|
|
|
assert(test_string("0x10203040", 0x10203040));
|
|
|
|
|
|
|
|
assert(test_keysym(0x1008FF56, "XF86Close"));
|
|
|
|
assert(test_keysym(0x0, "NoSymbol"));
|
|
|
|
assert(test_keysym(0x1008FE20, "XF86Ungrab"));
|
|
|
|
assert(test_keysym(0x01001234, "U1234"));
|
2009-01-20 19:57:22 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|