diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-05-10 14:57:51 -0400 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-05-10 15:00:55 -0400 |
commit | 042f472eaa773b4d12872932397e9da8abf8067d (patch) | |
tree | fa80c1698d8d1c5889b09cdcb64ef328141f2448 /src/test/test-terminal-util.c | |
parent | 003aa3e045d6fab051a9fd75fdf1da9ce98e554b (diff) | |
download | systemd-042f472eaa773b4d12872932397e9da8abf8067d.tar.gz |
test: add test that shows all colors we define
Diffstat (limited to 'src/test/test-terminal-util.c')
-rw-r--r-- | src/test/test-terminal-util.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/test-terminal-util.c b/src/test/test-terminal-util.c index 96d92279fb..0e563f5497 100644 --- a/src/test/test-terminal-util.c +++ b/src/test/test-terminal-util.c @@ -75,12 +75,45 @@ static void test_getttyname_malloc(void) { assert_se(PATH_IN_SET(ttyname, "ptmx", "pts/ptmx")); } +static void test_one_color(const char *name, const char *color) { + printf("<%s%s%s>\n", color, name, ansi_normal()); +} + +static void test_colors(void) { + log_info("/* %s */", __func__); + + test_one_color("normal", ansi_normal()); + test_one_color("highlight", ansi_highlight()); + test_one_color("red", ansi_red()); + test_one_color("green", ansi_green()); + test_one_color("yellow", ansi_yellow()); + test_one_color("blue", ansi_blue()); + test_one_color("megenta", ansi_magenta()); + test_one_color("grey", ansi_grey()); + test_one_color("highlight-red", ansi_highlight_red()); + test_one_color("highlight-green", ansi_highlight_green()); + test_one_color("highlight-yellow", ansi_highlight_yellow()); + test_one_color("highlight-blue", ansi_highlight_blue()); + test_one_color("highlight-magenta", ansi_highlight_magenta()); + test_one_color("highlight-grey", ansi_highlight_grey()); + + test_one_color("underline", ansi_underline()); + test_one_color("highlight-underline", ansi_highlight_underline()); + test_one_color("highlight-red-underline", ansi_highlight_red_underline()); + test_one_color("highlight-green-underline", ansi_highlight_green_underline()); + test_one_color("highlight-yellow-underline", ansi_highlight_yellow_underline()); + test_one_color("highlight-blue-underline", ansi_highlight_blue_underline()); + test_one_color("highlight-magenta-underline", ansi_highlight_magenta_underline()); + test_one_color("highlight-grey-underline", ansi_highlight_grey_underline()); +} + int main(int argc, char *argv[]) { test_setup_logging(LOG_INFO); test_default_term_for_tty(); test_read_one_char(); test_getttyname_malloc(); + test_colors(); return 0; } |