From 4dfd8b7b3a1b7c1bab141a3e503bed77b2198aa0 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 Apr 2021 22:03:29 +0200 Subject: Add last test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libterminput.c | 2 +- test.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libterminput.c b/libterminput.c index 2eb6b95..81656aa 100644 --- a/libterminput.c +++ b/libterminput.c @@ -800,7 +800,7 @@ again: p = stpcpy(&ctx->key[n], ret.symbol); /* Check if sequence is complete */ continue_incomplete: - if (!isalpha(p[-1]) && p[-1] != '~' && p[-1] != '@' && p[-1] != '^' && p[-1] != '$') { /* TODO test */ + if (!isalpha(p[-1]) && p[-1] != '~' && p[-1] != '@' && p[-1] != '^' && p[-1] != '$') { input->type = LIBTERMINPUT_NONE; return 1; } else if (ctx->key[0] == '[' && ctx->key[1] == '<' && p == &ctx->key[2]) { diff --git a/test.c b/test.c index bac8f8b..c801d39 100644 --- a/test.c +++ b/test.c @@ -286,6 +286,26 @@ main(void) TEST(input.keypress.mods == (MODS));\ TEST(input.keypress.times == times__);\ }\ + if (buffer[0] && buffer[1]) {\ + size_t i__;\ + for (i__ = 0; buffer[i__ + 1]; i__++) {\ + TEST(write(fds[1], &buffer[i__], 1) == 1);\ + TEST(libterminput_read(fds[0], &input, &ctx) == 1);\ + TEST(input.type == LIBTERMINPUT_NONE);\ + }\ + TEST(write(fds[1], &buffer[i__], 1) == 1);\ + TEST(libterminput_read(fds[0], &input, &ctx) == 1);\ + TEST(input.keypress.key == (KEY));\ + TEST(input.keypress.mods == (MODS));\ + TEST(input.keypress.times == (TIMES));\ + for (times__ = (TIMES) - 1; times__; times__--) {\ + TEST(libterminput_read(fds[0], &input, &ctx) == 1);\ + TEST(input.type == LIBTERMINPUT_KEYPRESS);\ + TEST(input.keypress.key == (KEY));\ + TEST(input.keypress.mods == (MODS));\ + TEST(input.keypress.times == times__);\ + }\ + }\ } while (0) #define KEYPRESS(A, B, KEY, MODS)\ -- cgit v1.2.3-70-g09d2