2014-10-14 00:24:47 +02:00
|
|
|
#include "../termo.h"
|
2011-04-02 16:07:30 +02:00
|
|
|
#include "taplib.h"
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2011-04-02 16:07:30 +02:00
|
|
|
{
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_t *tk;
|
|
|
|
termo_key_t key1, key2;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
plan_tests (12);
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
tk = termo_new_abstract ("vt100", NULL, 0);
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key1.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key1.code.codepoint = 'A';
|
|
|
|
key1.modifiers = 0;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_keycmp (tk, &key1, &key1), 0, "cmpkey same structure");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key2.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key2.code.codepoint = 'A';
|
|
|
|
key2.modifiers = 0;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_keycmp (tk, &key1, &key2), 0, "cmpkey identical structure");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key2.modifiers = TERMO_KEYMOD_CTRL;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key1, &key2) < 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders CTRL after nomod");
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key2, &key1) > 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders nomod before CTRL");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key2.code.codepoint = 'B';
|
|
|
|
key2.modifiers = 0;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key1, &key2) < 0, "cmpkey orders 'B' after 'A'");
|
|
|
|
ok (termo_keycmp (tk, &key2, &key1) > 0, "cmpkey orders 'A' before 'B'");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key1.modifiers = TERMO_KEYMOD_CTRL;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key1, &key2) < 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders nomod 'B' after CTRL 'A'");
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key2, &key1) > 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders CTRL 'A' before nomod 'B'");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key2.type = TERMO_TYPE_KEYSYM;
|
|
|
|
key2.code.sym = TERMO_SYM_UP;
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key1, &key2) < 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders KEYSYM after KEY");
|
2014-10-14 00:24:47 +02:00
|
|
|
ok (termo_keycmp (tk, &key2, &key1) > 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey orders KEY before KEYSYM");
|
2011-04-02 16:07:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key1.type = TERMO_TYPE_KEYSYM;
|
|
|
|
key1.code.sym = TERMO_SYM_SPACE;
|
2014-09-28 05:56:13 +02:00
|
|
|
key1.modifiers = 0;
|
2014-10-14 00:24:47 +02:00
|
|
|
key2.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key2.code.codepoint = ' ';
|
|
|
|
key2.modifiers = 0;
|
2011-09-06 23:49:05 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_keycmp (tk, &key1, &key2), 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey considers KEYSYM/SPACE and KEY/SP identical");
|
2011-09-06 23:49:05 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_set_canonflags (tk,
|
|
|
|
termo_get_canonflags (tk) | TERMO_CANON_SPACESYMBOL);
|
|
|
|
is_int (termo_keycmp (tk, &key1, &key2), 0,
|
2014-09-28 05:56:13 +02:00
|
|
|
"cmpkey considers KEYSYM/SPACE and KEY/SP"
|
|
|
|
" identical under SPACESYMBOL");
|
2011-09-06 23:49:05 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_destroy (tk);
|
2014-09-28 05:56:13 +02:00
|
|
|
return exit_status ();
|
2011-04-02 16:07:30 +02:00
|
|
|
}
|