diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 17:36:22 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 17:36:22 +0300 |
| commit | 13bf7edad251df9943bd75665a3510535849b0ac (patch) | |
| tree | 4597aae71940edac0b7d8b416c4803cd72ac5345 /tests | |
| parent | 513bf031a589d9e2a1a2730adf56f95e5e316a06 (diff) | |
Deduplicate scroll and SIMD paths while preserving performance
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/osc_test.c | 8 | ||||
| -rw-r--r-- | tests/term_test.c | 32 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/osc_test.c b/tests/osc_test.c index 4d0e32b..91b51d6 100644 --- a/tests/osc_test.c +++ b/tests/osc_test.c @@ -397,9 +397,14 @@ static void test_palette_and_theme(void) assert(term_color_parse("123456", &c) && c == 0xFF123456u); assert(term_color_parse("abc", &c) && c == 0xFFAABBCCu); assert(term_color_parse("#123456789abc", &c) && c == 0xFF12569au); + assert(term_color_parse("#123456789", &c) && c == 0xFF124578u); + assert(!term_color_parse("#12g456789", &c)); + assert(!term_color_parse("#123456789abg", &c)); /* rgb: / rgbi: */ assert(term_color_parse("rgb:ff/80/00", &c) && c == 0xFFFF8000u); + assert(term_color_parse("rgb:f/123/4567", &c) && c == 0xFFFF1245u); + assert(!term_color_parse("rgb:fffff/0/0", &c)); assert(term_color_parse("rgbi:1.0/0.0/0.5", &c) && c == 0xFFFF0080u); assert(term_color_parse("rgbi:.25/.5/.75", &c)); @@ -424,6 +429,9 @@ static void test_palette_and_theme(void) assert(term_theme_set_key(&theme, "color0", "") && theme.ansi[0] == 0xFF585B70u); assert(!term_theme_set_key(&theme, "color16", "#000000")); assert(!term_theme_set_key(&theme, "color01", "#000000")); + assert(!term_theme_set_key(&theme, "color", "#000000")); + assert(!term_theme_set_key(&theme, "color1x", "#000000")); + assert(!term_theme_set_key(&theme, "color100000000000000000000", "#000000")); assert(!term_theme_set_key(&theme, "invalid", "#000000")); assert(!term_theme_set_key(NULL, "foreground", "#000000")); assert(!term_theme_set_key(&theme, NULL, "#000000")); 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(); |
