diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-04-19 17:20:31 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-04-19 17:20:31 +0000 |
| commit | 70103339b017a42ea71a56c27c221a79ccc3116f (patch) | |
| tree | a1797800fb7ebeb1bdd8833d3bcc2503438de4f4 /test/libapt/configuration_test.cc | |
| parent | 633f6d67a28b375cf1f225f14d3c926e618d46af (diff) | |
| parent | 28ec28746d8633b9c4b67cd6d1b603a1da57f436 (diff) | |
Merge branch 'color-framework' into 'main'
Introduce APT::Configuration::Color, --color option and documentation for color.
See merge request apt-team/apt!342
Diffstat (limited to 'test/libapt/configuration_test.cc')
| -rw-r--r-- | test/libapt/configuration_test.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 4d297a9f2..61c7348a2 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -230,3 +230,33 @@ List::Option2 { "Multi"; EXPECT_TRUE(Cnf.FindB("Trailing")); EXPECT_FALSE(Cnf.Exists("Commented::Out")); } + +TEST(ConfigurationTest, Color) +{ + _config->Clear(); + _config->Set("APT::Color::Neutral", "\x1B[N"); + _config->Set("APT::Color::Green", "\x1B[G"); + // This is escaped for extra fun + _config->Set("APT::Color::Bold", "\\x1B[B"); + _config->Set("APT::Color::BoldGreen", "bold green"); + _config->Set("APT::Color::BoldGreenRef", "boldgreen"); + _config->Set("APT::Color::BoldGreenNeutral", "boldgreen neutral"); + _config->Set("APT::Color::BoldGreenRefNeutral", "boldgreenref neutral"); + + EXPECT_EQ("", APT::Configuration::color("bold")); + EXPECT_EQ("", APT::Configuration::color("green")); + EXPECT_EQ("content", APT::Configuration::color("green", "content")); + EXPECT_EQ("", APT::Configuration::color("boldgreen")); + EXPECT_EQ("", APT::Configuration::color("boldgreenref")); + EXPECT_EQ("", APT::Configuration::color("boldgreenneutral")); + EXPECT_EQ("", APT::Configuration::color("boldgreenrefneutral")); + + _config->Set("APT::Color", "true"); + EXPECT_EQ("\x1B[B", APT::Configuration::color("bold")); + EXPECT_EQ("\x1B[G", APT::Configuration::color("green")); + EXPECT_EQ("\x1B[Gcontent\x1B[N", APT::Configuration::color("green", "content")); + EXPECT_EQ("\x1B[B\x1B[G", APT::Configuration::color("boldgreen")); + EXPECT_EQ("\x1B[B\x1B[G", APT::Configuration::color("boldgreenref")); + EXPECT_EQ("\x1B[B\x1B[G\x1B[N", APT::Configuration::color("boldgreenneutral")); + EXPECT_EQ("\x1B[B\x1B[G\x1B[N", APT::Configuration::color("boldgreenrefneutral")); +} |
