tests: config: colors: verify loaded color is correct

This commit is contained in:
Daniel Eklöf 2025-04-20 07:29:54 +02:00
parent 5406ae3355
commit b24a9a59b9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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},