diff --git a/tests/standalone/Configuration/Argparse.cpp b/tests/standalone/Configuration/Argparse.cpp index 2f9e04c..cfaf142 100644 --- a/tests/standalone/Configuration/Argparse.cpp +++ b/tests/standalone/Configuration/Argparse.cpp @@ -175,6 +175,29 @@ Void::Testing::Test argparse_unknown_option_is_error() // ── help ────────────────────────────────────────────────────────────────────── +Void::Testing::Test argparse_help_color_default_and_toggle() +{ + ::unsetenv("NO_COLOR"); + bool v = false; + Parser p{"tool"}; + p.flag("--verbose", "-v", "verbose mode", v); + + const auto colored = p.help(); + Void::Testing::expect(colored.find("\033[") != std::string::npos); + Void::Testing::expect(colored.find("--verbose") != std::string::npos); + + p.color(false); + const auto plain = p.help(); + Void::Testing::expect(plain.find("\033[") == std::string::npos); + Void::Testing::expect(plain.find("--verbose") != std::string::npos); + + // NO_COLOR disables styling even when the parser allows it. + p.color(true); + ::setenv("NO_COLOR", "1", 1); + Void::Testing::expect(p.help().find("\033[") == std::string::npos); + ::unsetenv("NO_COLOR"); +} + Void::Testing::Test argparse_help_contains_names() { bool v = false;