diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
| commit | bdaedce69b17b654bd0060579dd9b9ff120009b5 (patch) | |
| tree | 0e9cd8597652263a96c48ba678fb0b66e1fc131b /tests/correctness_probe.c | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'tests/correctness_probe.c')
| -rw-r--r-- | tests/correctness_probe.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/tests/correctness_probe.c b/tests/correctness_probe.c index 9ac74ca..47548a3 100644 --- a/tests/correctness_probe.c +++ b/tests/correctness_probe.c @@ -27,60 +27,60 @@ void *__wrap_realloc(void *ptr, size_t size) int main(void) { bool failed = false; - struct term_options options = { .size = { 8, 3 }, .scrollback = 5 }; - struct term *t = term_new(&options); - struct term_snapshot *s = term_snapshot_new(); - assert(t && s && term_snapshot_update(s, t)); + struct wsap_vtcore_options options = { .size = { 8, 3 }, .scrollback = 5 }; + struct wsap_vtcore *t = wsap_vtcore_new(&options); + struct wsap_vtcore_snapshot *s = wsap_vtcore_snapshot_new(); + assert(t && s && wsap_vtcore_snapshot_update(s, t)); const char accented[] = "e\xcc\x81"; - term_feed(t, accented, sizeof(accented) - 1, 0); + wsap_vtcore_feed(t, accented, sizeof(accented) - 1, 0); fail_realloc = 1; - bool ok = term_snapshot_update(s, t); + bool ok = wsap_vtcore_snapshot_update(s, t); uint32_t cps[16]; printf("snapshot arena allocation failure: update=%d size=%dx%d (expected false and the previous 8x3 view)\n", - ok, term_snapshot_view(s)->size.x, term_snapshot_view(s)->size.y); - failed |= ok || term_snapshot_view(s)->size.x != 8 || term_snapshot_view(s)->size.y != 3; - assert(term_snapshot_update(s, t)); - int n = term_snapshot_cluster(s, term_snapshot_row(s, 0)[0].text, cps, 16); + ok, wsap_vtcore_snapshot_view(s)->size.x, wsap_vtcore_snapshot_view(s)->size.y); + failed |= ok || wsap_vtcore_snapshot_view(s)->size.x != 8 || wsap_vtcore_snapshot_view(s)->size.y != 3; + assert(wsap_vtcore_snapshot_update(s, t)); + int n = wsap_vtcore_snapshot_cluster(s, wsap_vtcore_snapshot_row(s, 0)[0].text, cps, 16); printf("retry after allocation recovers: cluster_length=%d (expected 2)\n", n); failed |= n != 2 || cps[0] != 'e' || cps[1] != 0x301; - term_snapshot_free(s); - term_free(t); + wsap_vtcore_snapshot_free(s); + wsap_vtcore_free(t); options.size.y = 24; - t = term_new(&options); - s = term_snapshot_new(); + t = wsap_vtcore_new(&options); + s = wsap_vtcore_snapshot_new(); assert(t && s); const char line[] = "e\xcc\x81\r\n"; for (int i = 1; i <= 10000; i++) { - term_feed(t, line, sizeof(line) - 1, 0); - assert(term_snapshot_update(s, t)); + wsap_vtcore_feed(t, line, sizeof(line) - 1, 0); + assert(wsap_vtcore_snapshot_update(s, t)); if (i == 1000 || i == 10000) printf("after %d lines: arena_words=%u dead_words=%u history_rows=%d\n", - i, s->arena_len, s->arena_dead, term_history_rows(t)); + i, s->arena_len, s->arena_dead, wsap_vtcore_history_rows(t)); } - failed |= s->arena_len >= 8192 || term_history_rows(t) != 5; - term_snapshot_free(s); - term_free(t); + failed |= s->arena_len >= 8192 || wsap_vtcore_history_rows(t) != 5; + wsap_vtcore_snapshot_free(s); + wsap_vtcore_free(t); - options.size = (struct term_vector2i){ 8, 4 }; - t = term_new(&options); - s = term_snapshot_new(); + options.size = (struct wsap_vtcore_vector2i){ 8, 4 }; + t = wsap_vtcore_new(&options); + s = wsap_vtcore_snapshot_new(); assert(t && s); const char rows[] = "A\r\nB\r\nC\r\nD"; - term_feed(t, rows, sizeof(rows) - 1, 0); - assert(term_snapshot_update(s, t)); + wsap_vtcore_feed(t, rows, sizeof(rows) - 1, 0); + assert(wsap_vtcore_snapshot_update(s, t)); printf("before failed height shrink: top=%c cursor_y=%d history=%d\n", - (char)term_snapshot_row(s, 0)[0].text, term_cursor(t).pos.y, term_history_rows(t)); + (char)wsap_vtcore_snapshot_row(s, 0)[0].text, wsap_vtcore_cursor(t).pos.y, wsap_vtcore_history_rows(t)); fail_resize_calloc = 1; - ok = term_resize(t, (struct term_vector2i){ 8, 2 }); + ok = wsap_vtcore_resize(t, (struct wsap_vtcore_vector2i){ 8, 2 }); assert(!fail_resize_calloc); - assert(term_snapshot_update(s, t)); + assert(wsap_vtcore_snapshot_update(s, t)); printf("after failed height shrink: resize=%d height=%d top=%c cursor_y=%d history=%d\n", - ok, term_size(t).y, (char)term_snapshot_row(s, 0)[0].text, - term_cursor(t).pos.y, term_history_rows(t)); - failed |= ok || term_size(t).y != 4 || term_snapshot_row(s, 0)[0].text != 'A' || - term_cursor(t).pos.y != 3 || term_history_rows(t) != 0; - term_snapshot_free(s); - term_free(t); + ok, wsap_vtcore_size(t).y, (char)wsap_vtcore_snapshot_row(s, 0)[0].text, + wsap_vtcore_cursor(t).pos.y, wsap_vtcore_history_rows(t)); + failed |= ok || wsap_vtcore_size(t).y != 4 || wsap_vtcore_snapshot_row(s, 0)[0].text != 'A' || + wsap_vtcore_cursor(t).pos.y != 3 || wsap_vtcore_history_rows(t) != 0; + wsap_vtcore_snapshot_free(s); + wsap_vtcore_free(t); return failed ? 1 : 0; } |
