From db6013f0a589994e17df4409f3f4fa14e6073648 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 23 Apr 2024 06:10:51 +0200 Subject: Merging upstream version 2.9.2. Signed-off-by: Daniel Baumann --- test/libapt/configuration_test.cc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'test/libapt/configuration_test.cc') diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 4d297a9..37bc5ff 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -6,7 +6,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" @@ -230,3 +230,35 @@ 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")); + // Reset for other tests + _config->Clear(); +} -- cgit v1.2.3