2011-04-02 16:07:30 +02:00
|
|
|
#include "../termkey.h"
|
|
|
|
#include "taplib.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
TermKey *tk;
|
|
|
|
TermKeyKey key1, key2;
|
|
|
|
|
2011-09-06 23:49:05 +02:00
|
|
|
plan_tests(12);
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2012-01-26 13:55:34 +01:00
|
|
|
tk = termkey_new_abstract("vt100", 0);
|
2011-04-02 16:07:30 +02:00
|
|
|
|
|
|
|
key1.type = TERMKEY_TYPE_UNICODE;
|
|
|
|
key1.code.codepoint = 'A';
|
|
|
|
key1.modifiers = 0;
|
|
|
|
|
|
|
|
is_int(termkey_keycmp(tk, &key1, &key1), 0, "cmpkey same structure");
|
|
|
|
|
|
|
|
key2.type = TERMKEY_TYPE_UNICODE;
|
|
|
|
key2.code.codepoint = 'A';
|
|
|
|
key2.modifiers = 0;
|
|
|
|
|
|
|
|
is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey identical structure");
|
|
|
|
|
|
|
|
key2.modifiers = TERMKEY_KEYMOD_CTRL;
|
|
|
|
|
2011-04-08 00:31:43 +02:00
|
|
|
ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders CTRL after nomod");
|
|
|
|
ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders nomod before CTRL");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
|
|
|
key2.code.codepoint = 'B';
|
|
|
|
key2.modifiers = 0;
|
|
|
|
|
2011-04-08 00:31:43 +02:00
|
|
|
ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders 'B' after 'A'");
|
|
|
|
ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders 'A' before 'B'");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
|
|
|
key1.modifiers = TERMKEY_KEYMOD_CTRL;
|
|
|
|
|
2011-04-08 00:31:43 +02:00
|
|
|
ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders nomod 'B' after CTRL 'A'");
|
|
|
|
ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders CTRL 'A' before nomod 'B'");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
|
|
|
key2.type = TERMKEY_TYPE_KEYSYM;
|
|
|
|
key2.code.sym = TERMKEY_SYM_UP;
|
|
|
|
|
2011-04-08 00:31:43 +02:00
|
|
|
ok(termkey_keycmp(tk, &key1, &key2) < 0, "cmpkey orders KEYSYM after UNICODE");
|
|
|
|
ok(termkey_keycmp(tk, &key2, &key1) > 0, "cmpkey orders UNICODE before KEYSYM");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2011-09-06 23:49:05 +02:00
|
|
|
key1.type = TERMKEY_TYPE_KEYSYM;
|
|
|
|
key1.code.sym = TERMKEY_SYM_SPACE;
|
|
|
|
key1.modifiers = 0;
|
|
|
|
key2.type = TERMKEY_TYPE_UNICODE;
|
|
|
|
key2.code.codepoint = ' ';
|
|
|
|
key2.modifiers = 0;
|
|
|
|
|
|
|
|
is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical");
|
|
|
|
|
|
|
|
termkey_set_canonflags(tk, termkey_get_canonflags(tk) | TERMKEY_CANON_SPACESYMBOL);
|
|
|
|
is_int(termkey_keycmp(tk, &key1, &key2), 0, "cmpkey considers KEYSYM/SPACE and UNICODE/SP identical under SPACESYMBOL");
|
|
|
|
|
2011-04-02 16:07:30 +02:00
|
|
|
termkey_destroy(tk);
|
|
|
|
|
|
|
|
return exit_status();
|
|
|
|
}
|