summaryrefslogtreecommitdiff
path: root/tests/osc_test.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 13:04:32 +0300
commitbdaedce69b17b654bd0060579dd9b9ff120009b5 (patch)
tree0e9cd8597652263a96c48ba678fb0b66e1fc131b /tests/osc_test.c
parentba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff)
parentdcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff)
Merge branch 'wt/rename' into api-hardening
# Conflicts: # README.md
Diffstat (limited to 'tests/osc_test.c')
-rw-r--r--tests/osc_test.c232
1 files changed, 116 insertions, 116 deletions
diff --git a/tests/osc_test.c b/tests/osc_test.c
index 9d08157..66c6303 100644
--- a/tests/osc_test.c
+++ b/tests/osc_test.c
@@ -1,17 +1,17 @@
#include "term_api.h"
-#include "term/unicode/unicode.h"
+#include "wsap_vtcore/unicode/unicode.h"
#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-static void write_seq(struct term *t, const char *s)
+static void write_seq(struct wsap_vtcore *t, const char *s)
{
for (; *s; s++) tt_write(t, s, 1);
}
-static void write_buf(struct term *t, const char *s, size_t len)
+static void write_buf(struct wsap_vtcore *t, const char *s, size_t len)
{
tt_write(t, s, len);
}
@@ -55,9 +55,9 @@ static void capture_notify(void *ud, const char *t_, const char *b)
notify_count++;
}
-static struct term *osc_test_term(void)
+static struct wsap_vtcore *osc_test_term(void)
{
- struct term *t = tt_new_opts(80, 24, &(struct term_callbacks){
+ struct wsap_vtcore *t = tt_new_opts(80, 24, &(struct wsap_vtcore_callbacks){
.reply = capture_reply,
.title = capture_title,
.clipboard = capture_clip,
@@ -69,7 +69,7 @@ static struct term *osc_test_term(void)
/* Check the OSC 8 link or the detected URL at a viewport cell. NULL means
* no link. */
-static void assert_link(struct term *t, int col, int row, const char *want)
+static void assert_link(struct wsap_vtcore *t, int col, int row, const char *want)
{
char *url = tt_link_at(t, col, row);
if (want)
@@ -79,13 +79,13 @@ static void assert_link(struct term *t, int col, int row, const char *want)
free(url);
}
-static uint32_t cursor_color(struct term *t)
+static uint32_t cursor_color(struct wsap_vtcore *t)
{
- return term_snapshot_view(tt_snapshot_for(t))->palette[TERM_PALETTE_CURSOR];
+ return wsap_vtcore_snapshot_view(tt_snapshot_for(t))->palette[WSAP_VTCORE_PALETTE_CURSOR];
}
/* Send a color query and check the reply. */
-static void assert_query(struct term *t, const char *query, const char *want)
+static void assert_query(struct wsap_vtcore *t, const char *query, const char *want)
{
reply[0] = 0;
write_seq(t, query);
@@ -104,16 +104,16 @@ static void reset_captures(void)
notify_count = 0;
}
-/* The notification default is term_options.name. A DCS +p does not change it. */
+/* The notification default is wsap_vtcore_options.name. A DCS +p does not change it. */
static void test_host_name_notify(void)
{
- struct term_options opt = {
+ struct wsap_vtcore_options opt = {
.size = { .x = 80, .y = 24 },
.scrollback = TEST_SCROLLBACK,
.name = "myterm",
.callbacks = { .notify = capture_notify },
};
- struct term *t = term_new(&opt);
+ struct wsap_vtcore *t = wsap_vtcore_new(&opt);
assert(t);
reset_captures();
write_seq(t, "\033]9;hello\007");
@@ -130,12 +130,12 @@ static void test_host_name_notify(void)
write_seq(t, "\033]777;notify;Title;Body\007");
assert(notify_count == 2);
assert(!strcmp(notify_title, "Title"));
- term_free(t);
+ wsap_vtcore_free(t);
}
static void test_osc52(void)
{
- struct term *t = osc_test_term();
+ struct wsap_vtcore *t = osc_test_term();
reset_captures();
write_seq(t, "\033]52;c;aGVsbG8=\007");
assert(clip_count == 1 && !strcmp(clip_sel, "c"));
@@ -180,7 +180,7 @@ static void test_osc52(void)
write_seq(t, "\033]52;s;AAH9\007");
assert(clip_count == 1 && !strcmp(clip_sel, "s") && clip_len == 3);
assert(clip_data[0] == 0 && clip_data[1] == 1 && clip_data[2] == (char)0xfd);
- term_free(t);
+ wsap_vtcore_free(t);
}
/* An SGR reset must not drop an open link.
@@ -191,44 +191,44 @@ static void test_osc52(void)
* path runs. */
static void test_sgr_reset_keeps_link(void)
{
- struct term *t = osc_test_term();
+ struct wsap_vtcore *t = osc_test_term();
reset_captures();
static const char seq[] = "\033]8;;https://reset.dev\033\\\033[0mX";
write_buf(t, seq, sizeof(seq) - 1);
- assert(tt_cell(t, 0, 0)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 0, 0)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 0, 0, "https://reset.dev");
/* The same reset in its own write, which takes the normal parser. */
static const char seq2[] = "\033]8;;https://second.dev\033\\\033[0m";
write_buf(t, seq2, sizeof(seq2) - 1);
write_buf(t, "Y", 1);
- assert(tt_cell(t, 1, 0)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 1, 0)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 1, 0, "https://second.dev");
- term_free(t);
+ wsap_vtcore_free(t);
}
static void test_osc8(void)
{
- struct term *t = osc_test_term();
+ struct wsap_vtcore *t = osc_test_term();
reset_captures();
write_seq(t, "\033]8;;https://example.com\033\\link text\033]8;;\033\\after");
for (int c = 0; c < 9; c++) {
- assert(tt_cell(t, c, 0)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, c, 0)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, c, 0, "https://example.com");
}
for (int c = 9; c < 14; c++) {
- assert(!(tt_cell(t, c, 0)->attrs & TERM_ATTR_LINK));
+ assert(!(tt_cell(t, c, 0)->attrs & WSAP_VTCORE_ATTR_LINK));
assert_link(t, c, 0, NULL);
}
/* Each cell keeps the URI of its own link. */
write_seq(t, "\033[2;1H\033]8;;https://other.org\033\\bbb\033]8;;\033\\");
write_seq(t, "\033[3;1H\033]8;;https://example.com\033\\ccc\033]8;;\033\\");
- assert(tt_cell(t, 0, 1)->attrs & TERM_ATTR_LINK);
- assert(tt_cell(t, 0, 2)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 0, 1)->attrs & WSAP_VTCORE_ATTR_LINK);
+ assert(tt_cell(t, 0, 2)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 0, 1, "https://other.org");
assert_link(t, 2, 1, "https://other.org");
assert_link(t, 0, 2, "https://example.com");
@@ -236,31 +236,31 @@ static void test_osc8(void)
/* An erase removes the link. */
write_seq(t, "\033[4;1H\033]8;;https://gone.io\033\\zzz\033]8;;\033\\");
- assert(tt_cell(t, 0, 3)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 0, 3)->attrs & WSAP_VTCORE_ATTR_LINK);
write_seq(t, "\033[4;1H\033[K");
- assert(!(tt_cell(t, 0, 3)->attrs & TERM_ATTR_LINK));
+ assert(!(tt_cell(t, 0, 3)->attrs & WSAP_VTCORE_ATTR_LINK));
assert_link(t, 0, 3, NULL);
write_seq(t, "\033[5;1H\033]8;x\033\\nop\033]8;xyz\033\\qq");
- assert(!(tt_cell(t, 0, 4)->attrs & TERM_ATTR_LINK));
+ assert(!(tt_cell(t, 0, 4)->attrs & WSAP_VTCORE_ATTR_LINK));
assert_link(t, 0, 4, NULL);
- assert(!(tt_cell(t, 4, 4)->attrs & TERM_ATTR_LINK));
+ assert(!(tt_cell(t, 4, 4)->attrs & WSAP_VTCORE_ATTR_LINK));
write_seq(t, "\033]8;;https://stay.net\033\\\033]8;bogus\033\\ST\033]8;;\033\\");
- assert(tt_cell(t, 5, 4)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 5, 4)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 5, 4, "https://stay.net");
write_seq(t, "\033[6;1H\033]8;id=grp;https://params.dev\007p1\033]8;;\007");
- assert(tt_cell(t, 0, 5)->attrs & TERM_ATTR_LINK);
+ assert(tt_cell(t, 0, 5)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 0, 5, "https://params.dev");
/* A link stays on its cells when they scroll into the history. */
for (int i = 0; i < 30; i++)
write_buf(t, "filler\r\n", 8);
assert(tt_history(t) > 0);
- term_scroll(t, tt_history(t));
- assert(tt_view_cell(t, 0, 0)->attrs & TERM_ATTR_LINK);
+ wsap_vtcore_scroll(t, tt_history(t));
+ assert(tt_view_cell(t, 0, 0)->attrs & WSAP_VTCORE_ATTR_LINK);
assert_link(t, 0, 0, "https://example.com");
- term_scroll_to(t, 0);
+ wsap_vtcore_scroll_to(t, 0);
write_seq(t, "\033[7;1H");
for (int i = 0; i < 8300; i++) {
@@ -279,46 +279,46 @@ static void test_osc8(void)
write_seq(t, "\033[1;1H\033]8;;https://altscreen.test\033\\ALT\033]8;;\033\\");
assert_link(t, 0, 0, "https://altscreen.test");
write_seq(t, "\033[?1049l");
- term_scroll(t, tt_history(t));
+ wsap_vtcore_scroll(t, tt_history(t));
assert_link(t, 0, 0, "https://example.com");
- term_scroll_to(t, 0);
+ wsap_vtcore_scroll_to(t, 0);
write_seq(t, "\033[8;1HSee file:///home/user/code/file.c#L10-L20 for info");
assert_link(t, 10, 7, "file:///home/user/code/file.c#L10-L20");
- term_free(t);
+ wsap_vtcore_free(t);
}
-static bool text_is(char *(*get)(const struct term *),
- const struct term *t, const char *want)
+static bool text_is(char *(*get)(const struct wsap_vtcore *),
+ const struct wsap_vtcore *t, const char *want)
{
char *text = get(t);
bool same = text && !strcmp(text, want);
- term_text_free(text);
+ wsap_vtcore_text_free(text);
return same;
}
static void test_osc_misc(void)
{
- struct term *t = osc_test_term();
+ struct wsap_vtcore *t = osc_test_term();
reset_captures();
write_seq(t, "\033]7;file://host/home/user/proj\007");
- assert(text_is(term_cwd, t, "/home/user/proj"));
+ assert(text_is(wsap_vtcore_cwd, t, "/home/user/proj"));
write_seq(t, "\033]7;file:///a%20b\033\\");
- assert(text_is(term_cwd, t, "/a b"));
+ assert(text_is(wsap_vtcore_cwd, t, "/a b"));
const char *bulk = "\033]7;file://h/bulk%20dir\007";
write_buf(t, bulk, strlen(bulk));
- assert(text_is(term_cwd, t, "/bulk dir"));
+ assert(text_is(wsap_vtcore_cwd, t, "/bulk dir"));
write_seq(t, "\033]7;https://x/y\007");
write_seq(t, "\033]7;notauri\007");
- assert(text_is(term_cwd, t, "/bulk dir"));
+ assert(text_is(wsap_vtcore_cwd, t, "/bulk dir"));
write_seq(t, "\033]9;hello there\033\\");
assert(notify_count == 1);
- assert(!strcmp(notify_title, "term"));
+ assert(!strcmp(notify_title, "wsap_vtcore"));
assert(!strcmp(notify_body, "hello there"));
write_seq(t, "\033]9;4;3;50\007");
assert(notify_count == 1);
@@ -331,43 +331,43 @@ static void test_osc_misc(void)
assert(notify_count == 2);
write_seq(t, "\033]22;pointer\033\\");
- assert(text_is(term_pointer_shape, t, "pointer"));
+ assert(text_is(wsap_vtcore_pointer_shape, t, "pointer"));
write_seq(t, "\033]22;text\007");
- assert(text_is(term_pointer_shape, t, "text"));
+ assert(text_is(wsap_vtcore_pointer_shape, t, "text"));
write_seq(t, "\033]22;\033\\");
- assert(!term_pointer_shape(t));
+ assert(!wsap_vtcore_pointer_shape(t));
- term_free(t);
+ wsap_vtcore_free(t);
}
/* OSC 4, 10, 11, and 12 change the colors of one terminal. The reset codes
* restore the colors of its theme. */
static void test_osc_colors(void)
{
- struct term_theme theme;
- term_theme_default(&theme);
- struct term *t = osc_test_term();
- struct term *other = osc_test_term();
+ struct wsap_vtcore_theme theme;
+ wsap_vtcore_theme_default(&theme);
+ struct wsap_vtcore *t = osc_test_term();
+ struct wsap_vtcore *other = osc_test_term();
reset_captures();
/* tt_new starts with the built-in theme. */
- assert(tt_color(t, TERM_COLOR_FG) == 0xFFFFFFFFu && theme.fg == 0xFFFFFFFFu);
- assert(tt_color(t, TERM_COLOR_BG) == 0xFF1E1E2Eu && theme.bg == 0xFF1E1E2Eu);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_FG) == 0xFFFFFFFFu && theme.fg == 0xFFFFFFFFu);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_BG) == 0xFF1E1E2Eu && theme.bg == 0xFF1E1E2Eu);
assert(cursor_color(t) == 0xFF89B4FAu && theme.cursor == 0xFF89B4FAu);
assert_query(t, "\033]10;?\007", "\033]10;rgb:ffff/ffff/ffff\033\\");
write_seq(t, "\033]10;#ff0000\007");
- assert(tt_color(t, TERM_COLOR_FG) == 0xFFFF0000u);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_FG) == 0xFFFF0000u);
assert_query(t, "\033]10;?\007", "\033]10;rgb:ffff/0000/0000\033\\");
write_seq(t, "\033]110\007");
- assert(tt_color(t, TERM_COLOR_FG) == theme.fg);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_FG) == theme.fg);
assert_query(t, "\033]10;?\033\\", "\033]10;rgb:ffff/ffff/ffff\033\\");
write_seq(t, "\033]11;#00ff00\033\\");
- assert(tt_color(t, TERM_COLOR_BG) == 0xFF00FF00u);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_BG) == 0xFF00FF00u);
assert_query(t, "\033]11;?\007", "\033]11;rgb:0000/ffff/0000\033\\");
write_seq(t, "\033]111\007");
- assert(tt_color(t, TERM_COLOR_BG) == theme.bg);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_BG) == theme.bg);
assert_query(t, "\033]11;?\007", "\033]11;rgb:1e1e/1e1e/2e2e\033\\");
write_seq(t, "\033]12;#0000ff\007");
@@ -377,35 +377,35 @@ static void test_osc_colors(void)
assert(cursor_color(t) == theme.cursor);
assert_query(t, "\033]12;?\007", "\033]12;rgb:8989/b4b4/fafa\033\\");
- uint32_t ansi5 = tt_color(t, term_color_index(5));
+ uint32_t ansi5 = tt_color(t, wsap_vtcore_color_index(5));
assert(ansi5 == theme.ansi[5]);
write_seq(t, "\033]4;5;#ff0000\007");
- assert(tt_color(t, term_color_index(5)) == 0xFFFF0000u);
- assert(tt_color(t, term_color_index(4)) == theme.ansi[4]);
+ assert(tt_color(t, wsap_vtcore_color_index(5)) == 0xFFFF0000u);
+ assert(tt_color(t, wsap_vtcore_color_index(4)) == theme.ansi[4]);
/* A color change in one terminal does not change another terminal. */
write_seq(t, "\033]10;#123456\007");
- assert(tt_color(other, term_color_index(5)) == theme.ansi[5]);
- assert(tt_color(other, TERM_COLOR_FG) == theme.fg);
+ assert(tt_color(other, wsap_vtcore_color_index(5)) == theme.ansi[5]);
+ assert(tt_color(other, WSAP_VTCORE_COLOR_FG) == theme.fg);
assert_query(other, "\033]10;?\007", "\033]10;rgb:ffff/ffff/ffff\033\\");
- assert(tt_color(t, TERM_COLOR_FG) == 0xFF123456u);
+ assert(tt_color(t, WSAP_VTCORE_COLOR_FG) == 0xFF123456u);
write_seq(t, "\033]104;5\007");
- assert(tt_color(t, term_color_index(5)) == ansi5);
+ assert(tt_color(t, wsap_vtcore_color_index(5)) == ansi5);
write_seq(t, "\033]4;1;#010203;2;#040506\007");
- assert(tt_color(t, term_color_index(1)) == 0xFF010203u);
- assert(tt_color(t, term_color_index(2)) == 0xFF040506u);
+ assert(tt_color(t, wsap_vtcore_color_index(1)) == 0xFF010203u);
+ assert(tt_color(t, wsap_vtcore_color_index(2)) == 0xFF040506u);
write_seq(t, "\033]104\007");
- assert(tt_color(t, term_color_index(1)) == theme.ansi[1]);
- assert(tt_color(t, term_color_index(2)) == theme.ansi[2]);
+ assert(tt_color(t, wsap_vtcore_color_index(1)) == theme.ansi[1]);
+ assert(tt_color(t, wsap_vtcore_color_index(2)) == theme.ansi[2]);
- term_free(other);
- term_free(t);
+ wsap_vtcore_free(other);
+ wsap_vtcore_free(t);
}
static void test_osc_legacy_titles(void)
{
- struct term *t = osc_test_term();
+ struct wsap_vtcore *t = osc_test_term();
reset_captures();
write_seq(t, "\033]legacy title\007");
@@ -415,61 +415,61 @@ static void test_osc_legacy_titles(void)
write_seq(t, "\033]2adjacent\033\\");
assert(!strcmp(title, "adjacent"));
- term_free(t);
+ wsap_vtcore_free(t);
}
static void test_palette_and_theme(void)
{
uint32_t c;
/* Hex formats */
- assert(term_color_parse("#f00", &c) && c == 0xFFFF0000u);
- assert(term_color_parse("#00ff00", &c) && c == 0xFF00FF00u);
- assert(term_color_parse(" #0000ff \t", &c) && c == 0xFF0000FFu);
- 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));
+ assert(wsap_vtcore_color_parse("#f00", &c) && c == 0xFFFF0000u);
+ assert(wsap_vtcore_color_parse("#00ff00", &c) && c == 0xFF00FF00u);
+ assert(wsap_vtcore_color_parse(" #0000ff \t", &c) && c == 0xFF0000FFu);
+ assert(wsap_vtcore_color_parse("123456", &c) && c == 0xFF123456u);
+ assert(wsap_vtcore_color_parse("abc", &c) && c == 0xFFAABBCCu);
+ assert(wsap_vtcore_color_parse("#123456789abc", &c) && c == 0xFF12569au);
+ assert(wsap_vtcore_color_parse("#123456789", &c) && c == 0xFF124578u);
+ assert(!wsap_vtcore_color_parse("#12g456789", &c));
+ assert(!wsap_vtcore_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));
+ assert(wsap_vtcore_color_parse("rgb:ff/80/00", &c) && c == 0xFFFF8000u);
+ assert(wsap_vtcore_color_parse("rgb:f/123/4567", &c) && c == 0xFFFF1245u);
+ assert(!wsap_vtcore_color_parse("rgb:fffff/0/0", &c));
+ assert(wsap_vtcore_color_parse("rgbi:1.0/0.0/0.5", &c) && c == 0xFFFF0080u);
+ assert(wsap_vtcore_color_parse("rgbi:.25/.5/.75", &c));
/* Errors */
- assert(!term_color_parse(NULL, &c));
- assert(!term_color_parse("#ff", &c));
- assert(!term_color_parse("", &c));
- assert(!term_color_parse("rgb:ff/80", &c));
- assert(!term_color_parse("rgb:ff/80/00/11", &c));
- assert(!term_color_parse("rgbi:2.0/0/0", &c));
- assert(!term_color_parse("rgbi:./0/0", &c));
+ assert(!wsap_vtcore_color_parse(NULL, &c));
+ assert(!wsap_vtcore_color_parse("#ff", &c));
+ assert(!wsap_vtcore_color_parse("", &c));
+ assert(!wsap_vtcore_color_parse("rgb:ff/80", &c));
+ assert(!wsap_vtcore_color_parse("rgb:ff/80/00/11", &c));
+ assert(!wsap_vtcore_color_parse("rgbi:2.0/0/0", &c));
+ assert(!wsap_vtcore_color_parse("rgbi:./0/0", &c));
/* Theme APIs */
- struct term_theme theme;
- term_theme_default(&theme);
- assert(term_theme_set_key(&theme, "foreground", "#112233") && theme.fg == 0xFF112233u);
- assert(term_theme_set_key(&theme, "foreground", "") && theme.fg == 0xFFFFFFFFu);
- assert(term_theme_set_key(&theme, "background", "#445566") && theme.bg == 0xFF445566u);
- assert(term_theme_set_key(&theme, "background", "") && theme.bg == 0xFF1E1E2Eu);
- assert(term_theme_set_key(&theme, "color0", "#010203") && theme.ansi[0] == 0xFF010203u);
- assert(term_theme_set_key(&theme, "color15", "#fafbfc") && theme.ansi[15] == 0xFFFAFBFCu);
- 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"));
- assert(!term_theme_set_key(&theme, "foreground", NULL));
-
- struct term_theme hc;
- term_theme_high_contrast(&hc);
+ struct wsap_vtcore_theme theme;
+ wsap_vtcore_theme_default(&theme);
+ assert(wsap_vtcore_theme_set_key(&theme, "foreground", "#112233") && theme.fg == 0xFF112233u);
+ assert(wsap_vtcore_theme_set_key(&theme, "foreground", "") && theme.fg == 0xFFFFFFFFu);
+ assert(wsap_vtcore_theme_set_key(&theme, "background", "#445566") && theme.bg == 0xFF445566u);
+ assert(wsap_vtcore_theme_set_key(&theme, "background", "") && theme.bg == 0xFF1E1E2Eu);
+ assert(wsap_vtcore_theme_set_key(&theme, "color0", "#010203") && theme.ansi[0] == 0xFF010203u);
+ assert(wsap_vtcore_theme_set_key(&theme, "color15", "#fafbfc") && theme.ansi[15] == 0xFFFAFBFCu);
+ assert(wsap_vtcore_theme_set_key(&theme, "color0", "") && theme.ansi[0] == 0xFF585B70u);
+ assert(!wsap_vtcore_theme_set_key(&theme, "color16", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "color01", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "color", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "color1x", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "color100000000000000000000", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "invalid", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(NULL, "foreground", "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, NULL, "#000000"));
+ assert(!wsap_vtcore_theme_set_key(&theme, "foreground", NULL));
+
+ struct wsap_vtcore_theme hc;
+ wsap_vtcore_theme_high_contrast(&hc);
assert(hc.bg == 0xFF000000u && hc.fg == 0xFFFFFFFFu);
}