diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-18 13:39:50 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-18 13:39:50 +0000 |
commit | 82ad14175cbcc7c0c660720c7a31f8e6f1cefe4e (patch) | |
tree | 8c20d19ebbf277de41a1d89167576a4b087f6011 /t/02getkey.c | |
parent | 082b49f0f8790e2cf98346a03c53f492d9d5dcba (diff) | |
download | termo-82ad14175cbcc7c0c660720c7a31f8e6f1cefe4e.tar.gz termo-82ad14175cbcc7c0c660720c7a31f8e6f1cefe4e.tar.xz termo-82ad14175cbcc7c0c660720c7a31f8e6f1cefe4e.zip |
Added termkey_push_bytes(), a new API for providing input bytes
Diffstat (limited to 't/02getkey.c')
-rw-r--r-- | t/02getkey.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/t/02getkey.c b/t/02getkey.c index 79d7976..6d076cb 100644 --- a/t/02getkey.c +++ b/t/02getkey.c @@ -4,30 +4,23 @@ int main(int argc, char *argv[]) { - int fd[2]; TermKey *tk; TermKeyKey key; - plan_tests(29); - - pipe(fd); + plan_tests(27); /* Sanitise this just in case */ putenv("TERM=vt100"); - tk = termkey_new(fd[0], TERMKEY_FLAG_NOTERMIOS); + tk = termkey_new(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); - - is_int(termkey_getkey(tk, &key), TERMKEY_RES_NONE, "getkey yields RES_NONE before advisereadable"); - - is_int(termkey_advisereadable(tk), TERMKEY_RES_AGAIN, "advisereadable yields RES_AGAIN after h"); + is_int(termkey_push_bytes(tk, "h", 1), 1, "push_bytes returns 1"); - is_int(termkey_get_buffer_remaining(tk), 255, "buffer free 255 after advisereadable"); + is_int(termkey_get_buffer_remaining(tk), 255, "buffer free 255 after push_bytes"); is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after h"); @@ -40,9 +33,7 @@ int main(int argc, char *argv[]) is_int(termkey_getkey(tk, &key), TERMKEY_RES_NONE, "getkey yields RES_NONE a second time"); - write(fd[1], "\x01", 1); - - is_int(termkey_advisereadable(tk), TERMKEY_RES_AGAIN, "advisereadable yields RES_AGAIN after C-a"); + termkey_push_bytes(tk, "\x01", 1); is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after C-a"); @@ -50,9 +41,7 @@ int main(int argc, char *argv[]) is_int(key.code.number, 'a', "key.code.number after C-a"); is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers after C-a"); - write(fd[1], "\eOA", 3); - - is_int(termkey_advisereadable(tk), TERMKEY_RES_AGAIN, "advisereadable yields RES_AGAIN after Up"); + termkey_push_bytes(tk, "\eOA", 3); is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after Up"); @@ -60,15 +49,13 @@ 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_push_bytes(tk, "\eO", 2), 2, "push_bytes returns 2"); 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); + termkey_push_bytes(tk, "C", 1); is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after Right completion"); |