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/api_args_test.c | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'tests/api_args_test.c')
| -rw-r--r-- | tests/api_args_test.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/tests/api_args_test.c b/tests/api_args_test.c index 6c7dfc7..309ee6e 100644 --- a/tests/api_args_test.c +++ b/tests/api_args_test.c @@ -4,7 +4,7 @@ #include <string.h> /* A feed that returns false must not move the cursor or change a cell. */ -static void expect_unchanged(struct term *t, int x, int y, uint32_t cp) +static void expect_unchanged(struct wsap_vtcore *t, int x, int y, uint32_t cp) { assert(tt_cursor_x(t) == x); assert(tt_cursor_y(t) == y); @@ -13,117 +13,117 @@ static void expect_unchanged(struct term *t, int x, int y, uint32_t cp) static void test_feed_unknown_flag(void) { - struct term *t = tt_new(10, 3); + struct wsap_vtcore *t = tt_new(10, 3); assert(t); - assert(term_feed(t, "abc", 3, 0)); + assert(wsap_vtcore_feed(t, "abc", 3, 0)); expect_unchanged(t, 3, 0, 'a'); - assert(!term_feed(t, "xy", 2, 1u << 1)); + assert(!wsap_vtcore_feed(t, "xy", 2, 1u << 1)); expect_unchanged(t, 3, 0, 'a'); - assert(!term_feed(t, "xy", 2, TERM_FEED_ONLCR | (1u << 4))); + assert(!wsap_vtcore_feed(t, "xy", 2, WSAP_VTCORE_FEED_ONLCR | (1u << 4))); expect_unchanged(t, 3, 0, 'a'); - assert(!term_feed(t, "xy", 2, 1u << 31)); + assert(!wsap_vtcore_feed(t, "xy", 2, 1u << 31)); expect_unchanged(t, 3, 0, 'a'); /* Unknown bits are rejected even when there are no bytes. */ - assert(!term_feed(t, "", 0, 1u << 1)); + assert(!wsap_vtcore_feed(t, "", 0, 1u << 1)); - assert(term_feed(t, "\nz", 2, TERM_FEED_ONLCR)); + assert(wsap_vtcore_feed(t, "\nz", 2, WSAP_VTCORE_FEED_ONLCR)); assert(tt_cursor_x(t) == 1); assert(tt_cursor_y(t) == 1); - term_free(t); + wsap_vtcore_free(t); } static void test_feed_null_buffer(void) { - struct term *t = tt_new(10, 3); + struct wsap_vtcore *t = tt_new(10, 3); assert(t); - assert(term_feed(t, "abc", 3, 0)); + assert(wsap_vtcore_feed(t, "abc", 3, 0)); - assert(!term_feed(t, NULL, 1, 0)); + assert(!wsap_vtcore_feed(t, NULL, 1, 0)); expect_unchanged(t, 3, 0, 'a'); - assert(!term_feed(t, NULL, 4096, TERM_FEED_ONLCR)); + assert(!wsap_vtcore_feed(t, NULL, 4096, WSAP_VTCORE_FEED_ONLCR)); expect_unchanged(t, 3, 0, 'a'); /* A zero length is a no-op, so a NULL buffer is fine. */ - assert(term_feed(t, NULL, 0, 0)); - assert(term_feed(t, "", 0, TERM_FEED_ONLCR)); + assert(wsap_vtcore_feed(t, NULL, 0, 0)); + assert(wsap_vtcore_feed(t, "", 0, WSAP_VTCORE_FEED_ONLCR)); expect_unchanged(t, 3, 0, 'a'); - assert(!term_feed(NULL, "a", 1, 0)); - assert(!term_feed(NULL, NULL, 0, 0)); - term_free(t); + assert(!wsap_vtcore_feed(NULL, "a", 1, 0)); + assert(!wsap_vtcore_feed(NULL, NULL, 0, 0)); + wsap_vtcore_free(t); } static void test_new_rejects_bad_options(void) { - struct term_options opt; + struct wsap_vtcore_options opt; memset(&opt, 0, sizeof(opt)); opt.size.x = -1; - assert(!term_new(&opt)); + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); opt.size.y = -1; - assert(!term_new(&opt)); + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); - opt.size.x = TERM_MAX_COLS + 1; - assert(!term_new(&opt)); + opt.size.x = WSAP_VTCORE_MAX_COLS + 1; + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); opt.scrollback = -1; - assert(!term_new(&opt)); + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); - opt.scrollback = TERM_SCROLLBACK_MAX + 1; - assert(!term_new(&opt)); + opt.scrollback = WSAP_VTCORE_SCROLLBACK_MAX + 1; + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); - opt.scrollback = TERM_SCROLLBACK_MAX; - struct term *max = term_new(&opt); + opt.scrollback = WSAP_VTCORE_SCROLLBACK_MAX; + struct wsap_vtcore *max = wsap_vtcore_new(&opt); assert(max); - term_free(max); + wsap_vtcore_free(max); memset(&opt, 0, sizeof(opt)); - opt.cursor_style = (enum term_cursor_style)3; - assert(!term_new(&opt)); + opt.cursor_style = (enum wsap_vtcore_cursor_style)3; + assert(!wsap_vtcore_new(&opt)); memset(&opt, 0, sizeof(opt)); - opt.cursor_style = (enum term_cursor_style)-1; - assert(!term_new(&opt)); + opt.cursor_style = (enum wsap_vtcore_cursor_style)-1; + assert(!wsap_vtcore_new(&opt)); } static void test_new_accepts_defaults(void) { - struct term_options opt; + struct wsap_vtcore_options opt; memset(&opt, 0, sizeof(opt)); - struct term *t = term_new(&opt); + struct wsap_vtcore *t = wsap_vtcore_new(&opt); assert(t); assert(tt_cols(t) == 80); assert(tt_rows(t) == 24); - assert(term_cursor(t).style == TERM_CURSOR_BLOCK); - term_free(t); + assert(wsap_vtcore_cursor(t).style == WSAP_VTCORE_CURSOR_BLOCK); + wsap_vtcore_free(t); memset(&opt, 0, sizeof(opt)); - opt.size.x = TERM_MAX_COLS; + opt.size.x = WSAP_VTCORE_MAX_COLS; opt.size.y = 1; - opt.cursor_style = TERM_CURSOR_BAR; - t = term_new(&opt); + opt.cursor_style = WSAP_VTCORE_CURSOR_BAR; + t = wsap_vtcore_new(&opt); assert(t); - assert(tt_cols(t) == TERM_MAX_COLS); + assert(tt_cols(t) == WSAP_VTCORE_MAX_COLS); assert(tt_rows(t) == 1); - assert(term_cursor(t).style == TERM_CURSOR_BAR); - term_free(t); + assert(wsap_vtcore_cursor(t).style == WSAP_VTCORE_CURSOR_BAR); + wsap_vtcore_free(t); } static void test_resize_rejects_too_wide(void) { - struct term *t = tt_new(10, 3); + struct wsap_vtcore *t = tt_new(10, 3); assert(t); - assert(term_feed(t, "abc", 3, 0)); + assert(wsap_vtcore_feed(t, "abc", 3, 0)); - assert(!tt_resize(t, TERM_MAX_COLS + 1, 3)); + assert(!tt_resize(t, WSAP_VTCORE_MAX_COLS + 1, 3)); assert(tt_cols(t) == 10); assert(tt_rows(t) == 3); expect_unchanged(t, 3, 0, 'a'); @@ -133,10 +133,10 @@ static void test_resize_rejects_too_wide(void) assert(tt_cols(t) == 10); assert(tt_rows(t) == 3); - assert(tt_resize(t, TERM_MAX_COLS, 3)); - assert(tt_cols(t) == TERM_MAX_COLS); + assert(tt_resize(t, WSAP_VTCORE_MAX_COLS, 3)); + assert(tt_cols(t) == WSAP_VTCORE_MAX_COLS); assert(tt_rows(t) == 3); - term_free(t); + wsap_vtcore_free(t); } int main(void) |
