skip to content
==> tests/style.c <==
1/* Style patching as ratatui's Style::patch tests specify it. */
2#include "mesh/check.h"
3#include "tui/style.h"
4
5int main(void) {
6    tui_style a = tui_style_add(tui_fg(TUI_RED), TUI_BOLD | TUI_ITALIC);
7    tui_style b = tui_style_remove(tui_style_bg(tui_style_new(), TUI_BLUE), TUI_ITALIC);
8    tui_style p = tui_style_patch(a, b);
9    CHECK(p.has_fg && tui_color_eq(p.fg, TUI_RED));
10    CHECK(p.has_bg && tui_color_eq(p.bg, TUI_BLUE));
11    CHECK_U(p.add, TUI_BOLD);
12    CHECK_U(p.sub, TUI_ITALIC);
13    /* An empty style changes nothing. */
14    CHECK(tui_style_eq(tui_style_patch(a, tui_style_new()), a));
15    /* add after remove clears the remove. */
16    tui_style c = tui_style_add(tui_style_remove(tui_style_new(), TUI_BOLD), TUI_BOLD);
17    CHECK_U(c.add, TUI_BOLD);
18    CHECK_U(c.sub, 0);
19    CHECK(!tui_color_eq(TUI_RGB(1, 2, 3), TUI_RGB(1, 2, 4)));
20    CHECK(tui_color_eq(TUI_WHITE, TUI_NAMED(15)));
21    return mesh_check_done();
22}