From 24abb0c59e78c2b7a660ca05f5afb6c514555ca5 Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Mon, 26 Aug 2013 00:56:07 +0100 Subject: Added TERMKEY_FORMAT_SPACEMOD --- t/11strfkey.c | 15 ++++++++++++++- t/12strpkey.c | 10 +++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/11strfkey.c b/t/11strfkey.c index bea3a22..20d822f 100644 --- a/t/11strfkey.c +++ b/t/11strfkey.c @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) char buffer[16]; size_t len; - plan_tests(28); + plan_tests(32); tk = termkey_new_abstract("vt100", 0); @@ -38,6 +38,11 @@ int main(int argc, char *argv[]) is_int(len, 6, "length for unicode/b/CTRL longmod"); is_str(buffer, "Ctrl-b", "buffer for unicode/b/CTRL longmod"); + len = termkey_strfkey(tk, buffer, sizeof buffer, &key, + TERMKEY_FORMAT_LONGMOD|TERMKEY_FORMAT_SPACEMOD); + is_int(len, 6, "length for unicode/b/CTRL longmod|spacemod"); + is_str(buffer, "Ctrl b", "buffer for unicode/b/CTRL longmod|spacemod"); + len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_CARETCTRL); is_int(len, 2, "length for unicode/b/CTRL caretctrl"); is_str(buffer, "^B", "buffer for unicode/b/CTRL caretctrl"); @@ -79,6 +84,14 @@ int main(int argc, char *argv[]) is_int(len, 4, "length for sym/Up/0 wrapbracket"); is_str(buffer, "", "buffer for sym/Up/0 wrapbracket"); + key.type = TERMKEY_TYPE_KEYSYM; + key.code.sym = TERMKEY_SYM_PAGEUP; + key.modifiers = 0; + + len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0); + is_int(len, 6, "length for sym/PageUp/0"); + is_str(buffer, "PageUp", "buffer for sym/PageUp/0"); + key.type = TERMKEY_TYPE_FUNCTION; key.code.number = 5; key.modifiers = 0; diff --git a/t/12strpkey.c b/t/12strpkey.c index 28c32f5..9f20883 100644 --- a/t/12strpkey.c +++ b/t/12strpkey.c @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) #define CLEAR_KEY do { key.type = -1; key.code.codepoint = -1; key.modifiers = -1; key.utf8[0] = 0; } while(0) - plan_tests(53); + plan_tests(58); tk = termkey_new_abstract("vt100", 0); @@ -85,6 +85,14 @@ int main(int argc, char *argv[]) is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT altismeta+longmod"); is_str(endp, "", "consumed entire input for unicode/c/ALT altismeta+longmod"); + CLEAR_KEY; + endp = termkey_strpkey(tk, "Meta c", &key, TERMKEY_FORMAT_ALTISMETA|TERMKEY_FORMAT_LONGMOD|TERMKEY_FORMAT_SPACEMOD); + is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type for unicode/c/ALT altismeta+long/lowermod"); + is_int(key.code.codepoint, 'c', "key.code.codepoint for unicode/c/ALT altismeta+long/lowermod"); + is_int(key.modifiers, TERMKEY_KEYMOD_ALT, "key.modifiers for unicode/c/ALT altismeta+long/lowermod"); + is_str(key.utf8, "c", "key.utf8 for unicode/c/ALT altismeta+long/lowermod"); + is_str(endp, "", "consumed entire input for unicode/c/ALT altismeta+longmod"); + CLEAR_KEY; endp = termkey_strpkey(tk, "Up", &key, 0); is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type for sym/Up/0"); -- cgit v1.2.3-70-g09d2