diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-08-27 19:59:02 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-08-27 19:59:02 +0100 |
commit | 46eefda07367e63b7ceffeecb2778409f1d4b387 (patch) | |
tree | 811bf778119fa1fc67c803ea8cc22a2e6252dd21 /t/20canon.c | |
parent | 83ca948d7818b88fa604a39a73465ba6932d4ce5 (diff) | |
download | termo-46eefda07367e63b7ceffeecb2778409f1d4b387.tar.gz termo-46eefda07367e63b7ceffeecb2778409f1d4b387.tar.xz termo-46eefda07367e63b7ceffeecb2778409f1d4b387.zip |
Provide an explicit termkey_canonicalise() function; canonicalise Space/SP in both directions
Diffstat (limited to 't/20canon.c')
-rw-r--r-- | t/20canon.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/20canon.c b/t/20canon.c new file mode 100644 index 0000000..b407f9f --- /dev/null +++ b/t/20canon.c @@ -0,0 +1,51 @@ +#include "../termkey.h" +#include "taplib.h" + +int main(int argc, char *argv[]) +{ + TermKey *tk; + TermKeyKey key; + char *endp; + +#define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) + + plan_tests(18); + + tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS); + + CLEAR_KEY; + endp = termkey_strpkey(tk, " ", &key, 0); + is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for SP/unicode"); + is_int(key.code.codepoint, ' ', "key.code.codepoint for SP/unicode"); + is_int(key.modifiers, 0, "key.modifiers for SP/unicode"); + is_str(key.utf8, " ", "key.utf8 for SP/unicode"); + is_str(endp, "", "consumed entire input for SP/unicode"); + + CLEAR_KEY; + endp = termkey_strpkey(tk, "Space", &key, 0); + is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for Space/unicode"); + is_int(key.code.codepoint, ' ', "key.code.codepoint for Space/unicode"); + is_int(key.modifiers, 0, "key.modifiers for Space/unicode"); + is_str(key.utf8, " ", "key.utf8 for Space/unicode"); + is_str(endp, "", "consumed entire input for Space/unicode"); + + termkey_set_flags(tk, termkey_get_flags(tk) | TERMKEY_FLAG_SPACESYMBOL); + + CLEAR_KEY; + endp = termkey_strpkey(tk, " ", &key, 0); + is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for SP/symbol"); + is_int(key.code.sym, TERMKEY_SYM_SPACE, "key.code.codepoint for SP/symbol"); + is_int(key.modifiers, 0, "key.modifiers for SP/symbol"); + is_str(endp, "", "consumed entire input for SP/symbol"); + + CLEAR_KEY; + endp = termkey_strpkey(tk, "Space", &key, 0); + is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for Space/symbol"); + is_int(key.code.sym, TERMKEY_SYM_SPACE, "key.code.codepoint for Space/symbol"); + is_int(key.modifiers, 0, "key.modifiers for Space/symbol"); + is_str(endp, "", "consumed entire input for Space/symbol"); + + termkey_destroy(tk); + + return exit_status(); +} |