From 13bf7edad251df9943bd75665a3510535849b0ac Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Wed, 14 Oct 2026 17:36:22 +0300 Subject: Deduplicate scroll and SIMD paths while preserving performance --- tests/term_test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/term_test.c') 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(); -- cgit v1.2.3