summaryrefslogtreecommitdiff
path: root/tests/term_test.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-14 17:36:22 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-14 17:36:22 +0300
commit13bf7edad251df9943bd75665a3510535849b0ac (patch)
tree4597aae71940edac0b7d8b416c4803cd72ac5345 /tests/term_test.c
parent513bf031a589d9e2a1a2730adf56f95e5e316a06 (diff)
Deduplicate scroll and SIMD paths while preserving performance
Diffstat (limited to 'tests/term_test.c')
-rw-r--r--tests/term_test.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/term_test.c b/tests/term_test.c
index 02c050e..3721720 100644
--- a/tests/term_test.c
+++ b/tests/term_test.c
@@ -1173,6 +1173,37 @@ static void test_full_width_line_endings(void)
term_free(t);
}
+/* CRLFs at every mask boundary, followed by complete or interrupted lines. */
+static void test_batched_line_masks(void)
+{
+ static const char *const tails[] = {
+ "\r\nx\r\ny\r\n", "\r\nx\ny\r\n", "\r\nx\r\ny\t",
+ "\r\nx\r\ny\rQ", "\r\nx\033[32my\r\n",
+ };
+ for (int offset = 0; offset <= 65; offset++) {
+ for (size_t k = 0; k < sizeof(tails) / sizeof(tails[0]); k++) {
+ char input[256];
+ memset(input, 'a', (size_t)offset);
+ size_t n = (size_t)offset + strlen(tails[k]);
+ memcpy(input + offset, tails[k], strlen(tails[k]));
+ memset(input + n, 'z', 128);
+ n += 128;
+ struct term *bulk = tt_new(80, 3), *bytes = tt_new(80, 3);
+ /* A nondefault pen exercises the queued bulk path, not streaming. */
+ write_both(bulk, bytes, "\033[3;1H\033[31m");
+ tt_write(bulk, input, n);
+ for (size_t i = 0; i < n; i++) tt_write(bytes, input + i, 1);
+ write_both(bulk, bytes, "\033[b");
+ assert_same_screen(bulk, bytes);
+ term_scroll_to(bulk, INT_MAX);
+ term_scroll_to(bytes, INT_MAX);
+ assert_same_screen(bulk, bytes);
+ term_free(bulk);
+ term_free(bytes);
+ }
+ }
+}
+
/* Compare the screen, cursor, and scrollback for each input mode.
*
* Input mode | Byte-wise | 64 KiB bulk | 512 KiB single write
@@ -1820,6 +1851,7 @@ int main(void)
test_invalid_utf8_runs();
test_c0_ends_utf8_sequence();
test_full_width_line_endings();
+ test_batched_line_masks();
test_bulk_line_flood();
test_ascii_flood_edits();
test_margin_linefeed_bursts();