diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-18 10:04:15 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-18 10:04:15 +0000 |
commit | 9534330003bdfdbc6ac47ad08fdf15636e0d9518 (patch) | |
tree | b4e251fccfd2cc20d591983b31f0c5c9d030bc42 /t | |
parent | 37d8f18ab5ec138c79ec3b0fbbf8277826992a33 (diff) | |
download | termo-9534330003bdfdbc6ac47ad08fdf15636e0d9518.tar.gz termo-9534330003bdfdbc6ac47ad08fdf15636e0d9518.tar.xz termo-9534330003bdfdbc6ac47ad08fdf15636e0d9518.zip |
Provide new API function to determine how much buffer space remains in the instance
Diffstat (limited to 't')
-rw-r--r-- | t/02getkey.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/t/02getkey.c b/t/02getkey.c index 8b1881b..79d7976 100644 --- a/t/02getkey.c +++ b/t/02getkey.c @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) TermKey *tk; TermKeyKey key; - plan_tests(19); + plan_tests(29); pipe(fd); @@ -17,6 +17,8 @@ int main(int argc, char *argv[]) tk = termkey_new(fd[0], TERMKEY_FLAG_NOTERMIOS); + is_int(termkey_get_buffer_remaining(tk), 256, "buffer free initially 256"); + is_int(termkey_getkey(tk, &key), TERMKEY_RES_NONE, "getkey yields RES_NONE when empty"); write(fd[1], "h", 1); @@ -25,6 +27,8 @@ int main(int argc, char *argv[]) is_int(termkey_advisereadable(tk), TERMKEY_RES_AGAIN, "advisereadable yields RES_AGAIN after h"); + is_int(termkey_get_buffer_remaining(tk), 255, "buffer free 255 after advisereadable"); + is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after h"); is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type after h"); @@ -32,6 +36,8 @@ int main(int argc, char *argv[]) is_int(key.modifiers, 0, "key.modifiers after h"); is_str(key.utf8, "h", "key.utf8 after h"); + is_int(termkey_get_buffer_remaining(tk), 256, "buffer free 256 after getkey"); + is_int(termkey_getkey(tk, &key), TERMKEY_RES_NONE, "getkey yields RES_NONE a second time"); write(fd[1], "\x01", 1); @@ -54,6 +60,24 @@ int main(int argc, char *argv[]) is_int(key.code.sym, TERMKEY_SYM_UP, "key.code.sym after Up"); is_int(key.modifiers, 0, "key.modifiers after Up"); + write(fd[1], "\eO", 2); + termkey_advisereadable(tk); + + is_int(termkey_get_buffer_remaining(tk), 254, "buffer free 254 after partial write"); + + is_int(termkey_getkey(tk, &key), TERMKEY_RES_AGAIN, "getkey yields RES_AGAIN after partial write"); + + write(fd[1], "C", 1); + termkey_advisereadable(tk); + + is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after Right completion"); + + is_int(key.type, TERMKEY_TYPE_KEYSYM, "key.type after Right"); + is_int(key.code.sym, TERMKEY_SYM_RIGHT, "key.code.sym after Right"); + is_int(key.modifiers, 0, "key.modifiers after Right"); + + is_int(termkey_get_buffer_remaining(tk), 256, "buffer free 256 after completion"); + termkey_destroy(tk); return exit_status(); |