aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-04-20 05:29:54 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-04-26 12:20:57 +0000
commitb24a9a59b9db95fe9a5195a30d982d9ed2150a8e (patch)
treec7021901d051b0e5e0a89fb0a4d6e7a3424d3244
parentthemes: cursor.color -> colors.cursor (diff)
tests: config: colors: verify loaded color is correct
-rw-r--r--tests/test-config.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test-config.c b/tests/test-config.c
index 69d349b4..7dfb8556 100644
--- a/tests/test-config.c
+++ b/tests/test-config.c
@@ -399,6 +399,16 @@ test_color(struct context *ctx, bool (*parse_fun)(struct context *ctx),
BUG("[%s].%s=%s: failed to parse",
ctx->section, ctx->key, ctx->value);
}
+
+ uint32_t color = input[i].color;
+ if (alpha_allowed && strlen(input[i].option_string) == 6)
+ color |= 0xff000000;
+
+ if (*ptr != color) {
+ BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
+ ctx->section, ctx->key, ctx->value,
+ color, *ptr);
+ }
}
}
}
@@ -445,6 +455,18 @@ test_two_colors(struct context *ctx, bool (*parse_fun)(struct context *ctx),
BUG("[%s].%s=%s: failed to parse",
ctx->section, ctx->key, ctx->value);
}
+
+ if (*ptr1 != input[i].color1) {
+ BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
+ ctx->section, ctx->key, ctx->value,
+ input[i].color1, *ptr1);
+ }
+
+ if (*ptr2 != input[i].color2) {
+ BUG("[%s].%s=%s: expected 0x%08x, got 0x%08x",
+ ctx->section, ctx->key, ctx->value,
+ input[i].color2, *ptr2);
+ }
}
}
}
@@ -720,6 +742,10 @@ test_section_colors(void)
&conf.colors.search_box.match.fg,
&conf.colors.search_box.match.bg);
+ test_two_colors(&ctx, &parse_section_colors, "cursor", false,
+ &conf.colors.cursor.text,
+ &conf.colors.cursor.cursor);
+
test_enum(&ctx, &parse_section_colors, "alpha-mode", 3,
(const char *[]){"default", "matching", "all"},
(int []){ALPHA_MODE_DEFAULT, ALPHA_MODE_MATCHING, ALPHA_MODE_ALL},