summaryrefslogtreecommitdiff
path: root/tests/input_test.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 13:36:27 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 13:36:27 +0300
commit4741f7a6dfa144ce65cf3bbdd4a1bc6bee6df2e5 (patch)
tree97932e58eee98623b56a9d9181a3b4289b6ecfc1 /tests/input_test.c
parenta0fefd3856a4f03be0abbc51f7a9a0416db69eb5 (diff)
Optimize and simplify loops, table lookups, and branchless parsers
- Replace sequential colon-counting loop with branchless CTZ bitmask in src/pen.h - Replace linear strchr with 256-bit ASCII punctuation bitmask in src/selection.c - Flatten 3D color cube loop and precompute constants in src/palette.c - Use static 256-byte LUT for hex decoding and bsearch for termcap in src/escape.c - Replace capacity doubling while loops with branchless CLZ pow2 helpers across core - Use direct memset/memcpy in src/snapshot.c - Optimize input digit/byte formatting, alt-prefix path, and make keyboard state optional in src/input.c
Diffstat (limited to 'tests/input_test.c')
-rw-r--r--tests/input_test.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/input_test.c b/tests/input_test.c
index 6ee2caa..1a44f42 100644
--- a/tests/input_test.c
+++ b/tests/input_test.c
@@ -101,9 +101,22 @@ int main(void)
typed('b', TERM_MOD_ALT | TERM_MOD_CTRL); expect("\033\002");
K(.key = TERM_KEY_BACKSPACE, .mods = TERM_MOD_ALT); expect("\033\177");
K(.key = TERM_KEY_RETURN, .mods = TERM_MOD_ALT); expect("\033\r");
+ K(.key = TERM_KEY_TAB, .mods = TERM_MOD_ALT); expect("\033\t");
+ K(.key = TERM_KEY_TAB, .mods = TERM_MOD_ALT | TERM_MOD_SHIFT); expect("\033[Z");
+ K(.key = TERM_KEY_ESCAPE, .mods = TERM_MOD_ALT); expect("\033");
K(.key = TERM_KEY_LEFT, .mods = TERM_MOD_ALT); expect("\033[1;3D");
+ {
+ char b_null[16];
+ struct term_input_result r = term_input_encode_key(
+ NULL,
+ &(struct term_key_event){ .key = TERM_KEY_UP, .action = TERM_KEY_PRESS },
+ &(struct term_modes){0},
+ b_null, sizeof(b_null));
+ assert(r.status == TERM_INPUT_BYTES && r.len == 3 && !memcmp(b_null, "\033[A", 3));
+ }
+
K(.codepoint = 'b', .base = 'b', .text = 0x222B, .text_deferred = true);
expect("");