Commit: 5206f56b0bbbdb63c1b9fd6fc8bca6380601aa6d
Parent: 9b3eb37506c276ef2d7575f8abc1ece08b3e7f94
Author: Randy Palamar
Date: Mon, 28 Oct 2024 06:56:00 -0600
test: better check for unicode character splitting
Diffstat:
M | test.c | | | 24 | ++++++++++++++++-------- |
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/test.c b/test.c
@@ -243,8 +243,19 @@ static TEST_FN(cursor_at_line_boundary)
s8 red_dragon = utf8_encode(0x1F004);
long_line.data[SPLIT_LONG - 1] = red_dragon.data[0];
long_line.data[SPLIT_LONG + 0] = red_dragon.data[1];
- long_line.data[SPLIT_LONG + 1] = red_dragon.data[2];
- long_line.data[SPLIT_LONG + 2] = red_dragon.data[3];
+
+ s8 raw = launder_static_string(term, (s8){.len = SPLIT_LONG + 1, .data = long_line.data});
+ long_line = consume(long_line, SPLIT_LONG + 1);
+
+ LineBuf *lb = &term->views[term->view_idx].lines;
+ size line_count = lb->filled;
+ handle_input(term, arena, raw);
+
+ /* NOTE: ensure line didn't split on red dragon */
+ result.status = term->unprocessed_bytes != 0;
+
+ long_line.data[0] = red_dragon.data[2];
+ long_line.data[1] = red_dragon.data[3];
/* NOTE: shove a newline at the end so that the line completes */
long_line.data[long_line.len - 1] = '\n';
@@ -255,13 +266,10 @@ static TEST_FN(cursor_at_line_boundary)
long_line.data[SPLIT_LONG + 3] = ' ';
#endif
- s8 raw = launder_static_string(term, long_line);
-
- LineBuf *lb = &term->views[term->view_idx].lines;
- size line_count = lb->filled;
- /* NOTE: ensure line didn't split on red dragon */
+ raw = launder_static_string(term, long_line);
handle_input(term, arena, raw);
- result.status = line_length(lb->buf) > SPLIT_LONG;
+
+ result.status &= line_length(lb->buf) > SPLIT_LONG;
/* NOTE: check that cursor state was transferred */
Cursor line_end = simulate_line(term, lb->buf);