1 #include "../termkey.h"
2 #include "taplib.h"
3
main(int argc,char * argv[])4 int main(int argc, char *argv[])
5 {
6 TermKey *tk;
7 TermKeyKey key;
8 const char *endp;
9
10 #define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0)
11
12 plan_tests(26);
13
14 tk = termkey_new_abstract("vt100", 0);
15
16 CLEAR_KEY;
17 endp = termkey_strpkey(tk, " ", &key, 0);
18 is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for SP/unicode");
19 is_int(key.code.codepoint, ' ', "key.code.codepoint for SP/unicode");
20 is_int(key.modifiers, 0, "key.modifiers for SP/unicode");
21 is_str(key.utf8, " ", "key.utf8 for SP/unicode");
22 is_str(endp, "", "consumed entire input for SP/unicode");
23
24 CLEAR_KEY;
25 endp = termkey_strpkey(tk, "Space", &key, 0);
26 is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for Space/unicode");
27 is_int(key.code.codepoint, ' ', "key.code.codepoint for Space/unicode");
28 is_int(key.modifiers, 0, "key.modifiers for Space/unicode");
29 is_str(key.utf8, " ", "key.utf8 for Space/unicode");
30 is_str(endp, "", "consumed entire input for Space/unicode");
31
32 termkey_set_canonflags(tk, termkey_get_canonflags(tk) | TERMKEY_CANON_SPACESYMBOL);
33
34 CLEAR_KEY;
35 endp = termkey_strpkey(tk, " ", &key, 0);
36 is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for SP/symbol");
37 is_int(key.code.sym, TERMKEY_SYM_SPACE, "key.code.codepoint for SP/symbol");
38 is_int(key.modifiers, 0, "key.modifiers for SP/symbol");
39 is_str(endp, "", "consumed entire input for SP/symbol");
40
41 CLEAR_KEY;
42 endp = termkey_strpkey(tk, "Space", &key, 0);
43 is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for Space/symbol");
44 is_int(key.code.sym, TERMKEY_SYM_SPACE, "key.code.codepoint for Space/symbol");
45 is_int(key.modifiers, 0, "key.modifiers for Space/symbol");
46 is_str(endp, "", "consumed entire input for Space/symbol");
47
48 CLEAR_KEY;
49 endp = termkey_strpkey(tk, "DEL", &key, 0);
50 is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for Del/unconverted");
51 is_int(key.code.sym, TERMKEY_SYM_DEL, "key.code.codepoint for Del/unconverted");
52 is_int(key.modifiers, 0, "key.modifiers for Del/unconverted");
53 is_str(endp, "", "consumed entire input for Del/unconverted");
54
55 termkey_set_canonflags(tk, termkey_get_canonflags(tk) | TERMKEY_CANON_DELBS);
56
57 CLEAR_KEY;
58 endp = termkey_strpkey(tk, "DEL", &key, 0);
59 is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for Del/as-backspace");
60 is_int(key.code.sym, TERMKEY_SYM_BACKSPACE, "key.code.codepoint for Del/as-backspace");
61 is_int(key.modifiers, 0, "key.modifiers for Del/as-backspace");
62 is_str(endp, "", "consumed entire input for Del/as-backspace");
63
64 termkey_destroy(tk);
65
66 return exit_status();
67 }
68