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/acqprogress_test.cc | 2 +- test/libapt/authconf_test.cc | 2 +- test/libapt/cachefilter_test.cc | 2 +- test/libapt/cdrom_test.cc | 2 +- test/libapt/cdromfindpackages_test.cc | 2 +- test/libapt/commandline_test.cc | 2 +- test/libapt/common.h | 11 +++++++++ test/libapt/compareversion_test.cc | 2 +- test/libapt/configuration_test.cc | 34 ++++++++++++++++++++++++++- test/libapt/extracttar_test.cc | 2 +- test/libapt/file-helpers.cc | 2 +- test/libapt/fileutl_test.cc | 2 +- test/libapt/getarchitectures_test.cc | 2 +- test/libapt/getlanguages_test.cc | 2 +- test/libapt/getlistoffilesindir_test.cc | 2 +- test/libapt/globalerror_test.cc | 2 +- test/libapt/gtest_runner.cc | 2 +- test/libapt/hashsums_test.cc | 2 +- test/libapt/indexcopytosourcelist_test.cc | 2 +- test/libapt/install_progress_test.cc | 2 +- test/libapt/json_test.cc | 2 +- test/libapt/openmaybeclearsignedfile_test.cc | 2 +- test/libapt/parsedepends_test.cc | 35 +++++++++++++++++++++++++++- test/libapt/pattern_test.cc | 2 +- test/libapt/priority_test.cc | 2 +- test/libapt/sourcelist_test.cc | 2 +- test/libapt/srvrecs_test.cc | 2 +- test/libapt/stringview_test.cc | 2 +- test/libapt/strutil_test.cc | 2 +- test/libapt/tagfile_test.cc | 2 +- test/libapt/tagsection_test.cc | 2 +- test/libapt/teestream_test.cc | 2 +- test/libapt/uri_test.cc | 2 +- 33 files changed, 108 insertions(+), 32 deletions(-) create mode 100644 test/libapt/common.h (limited to 'test') diff --git a/test/libapt/acqprogress_test.cc b/test/libapt/acqprogress_test.cc index d4596c8..17a0416 100644 --- a/test/libapt/acqprogress_test.cc +++ b/test/libapt/acqprogress_test.cc @@ -4,7 +4,7 @@ #include #include #include -#include +#include "common.h" #include #include diff --git a/test/libapt/authconf_test.cc b/test/libapt/authconf_test.cc index 3a7b149..b301b8b 100644 --- a/test/libapt/authconf_test.cc +++ b/test/libapt/authconf_test.cc @@ -7,7 +7,7 @@ #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/cachefilter_test.cc b/test/libapt/cachefilter_test.cc index 08812e0..3e24010 100644 --- a/test/libapt/cachefilter_test.cc +++ b/test/libapt/cachefilter_test.cc @@ -5,7 +5,7 @@ #include -#include +#include "common.h" TEST(CacheFilterTest, ArchitectureSpecification) { diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc index 364971e..4c43f19 100644 --- a/test/libapt/cdrom_test.cc +++ b/test/libapt/cdrom_test.cc @@ -9,7 +9,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/cdromfindpackages_test.cc b/test/libapt/cdromfindpackages_test.cc index 9e13c1d..6d65867 100644 --- a/test/libapt/cdromfindpackages_test.cc +++ b/test/libapt/cdromfindpackages_test.cc @@ -10,7 +10,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc index cde80b4..035d698 100644 --- a/test/libapt/commandline_test.cc +++ b/test/libapt/commandline_test.cc @@ -4,7 +4,7 @@ #include #include -#include +#include "common.h" class CLT: public CommandLine { public: diff --git a/test/libapt/common.h b/test/libapt/common.h new file mode 100644 index 0000000..d69711d --- /dev/null +++ b/test/libapt/common.h @@ -0,0 +1,11 @@ +/* + * GTest is a horribly broken library needing lots of diagnostic overrides, + * do them here. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdouble-promotion" +#pragma GCC diagnostic ignored "-Wsign-promo" +#pragma GCC diagnostic ignored "-Wsign-compare" +#include +#pragma GCC diagnostic pop + diff --git a/test/libapt/compareversion_test.cc b/test/libapt/compareversion_test.cc index 0fe32cf..c8b9e41 100644 --- a/test/libapt/compareversion_test.cc +++ b/test/libapt/compareversion_test.cc @@ -28,7 +28,7 @@ #include #include -#include +#include "common.h" using namespace std; 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(); +} diff --git a/test/libapt/extracttar_test.cc b/test/libapt/extracttar_test.cc index 246aea7..b01846c 100644 --- a/test/libapt/extracttar_test.cc +++ b/test/libapt/extracttar_test.cc @@ -7,7 +7,7 @@ #include #include "assert.h" -#include +#include "common.h" class Stream : public pkgDirStream { diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc index bb7052b..541dea1 100644 --- a/test/libapt/file-helpers.cc +++ b/test/libapt/file-helpers.cc @@ -9,7 +9,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc index da772df..b35a2d4 100644 --- a/test/libapt/fileutl_test.cc +++ b/test/libapt/fileutl_test.cc @@ -12,7 +12,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/getarchitectures_test.cc b/test/libapt/getarchitectures_test.cc index 4f76722..a4ccf67 100644 --- a/test/libapt/getarchitectures_test.cc +++ b/test/libapt/getarchitectures_test.cc @@ -6,7 +6,7 @@ #include #include -#include +#include "common.h" TEST(ArchitecturesTest,SimpleLists) { diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index 7146c5a..941a152 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -14,7 +14,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/getlistoffilesindir_test.cc b/test/libapt/getlistoffilesindir_test.cc index f002355..d48f366 100644 --- a/test/libapt/getlistoffilesindir_test.cc +++ b/test/libapt/getlistoffilesindir_test.cc @@ -7,7 +7,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc index 42e8355..d6ef074 100644 --- a/test/libapt/globalerror_test.cc +++ b/test/libapt/globalerror_test.cc @@ -7,7 +7,7 @@ #include #include -#include +#include "common.h" TEST(GlobalErrorTest,BasicDiscard) { diff --git a/test/libapt/gtest_runner.cc b/test/libapt/gtest_runner.cc index 09fc55d..d0f81e2 100644 --- a/test/libapt/gtest_runner.cc +++ b/test/libapt/gtest_runner.cc @@ -5,7 +5,7 @@ #include #include -#include +#include "common.h" int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index 901150e..48d52ac 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -9,7 +9,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc index 7dbe973..a1fed06 100644 --- a/test/libapt/indexcopytosourcelist_test.cc +++ b/test/libapt/indexcopytosourcelist_test.cc @@ -7,7 +7,7 @@ #include #include -#include +#include "common.h" class NoCopy : private IndexCopy { public: diff --git a/test/libapt/install_progress_test.cc b/test/libapt/install_progress_test.cc index 7015c61..43c461e 100644 --- a/test/libapt/install_progress_test.cc +++ b/test/libapt/install_progress_test.cc @@ -5,7 +5,7 @@ #include #include -#include +#include "common.h" TEST(InstallProgressTest, FancyGetTextProgressStr) { diff --git a/test/libapt/json_test.cc b/test/libapt/json_test.cc index ee8f3ce..6ab13a3 100644 --- a/test/libapt/json_test.cc +++ b/test/libapt/json_test.cc @@ -1,7 +1,7 @@ #include #include "../../apt-private/private-cachefile.cc" #include "../../apt-private/private-json-hooks.cc" -#include +#include "common.h" #include TEST(JsonTest, JsonString) diff --git a/test/libapt/openmaybeclearsignedfile_test.cc b/test/libapt/openmaybeclearsignedfile_test.cc index 4db8967..3979d85 100644 --- a/test/libapt/openmaybeclearsignedfile_test.cc +++ b/test/libapt/openmaybeclearsignedfile_test.cc @@ -6,7 +6,7 @@ #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index f641c8c..9771c5d 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -7,7 +7,7 @@ #include #include -#include +#include "common.h" static void parseDependency(bool const StripMultiArch, bool const ParseArchFlags, bool const ParseRestrictionsList, std::string Arch) { @@ -278,3 +278,36 @@ test: if (runner < 8) goto test; // this is the prove: tests are really evil ;) } + +TEST(ParseDependsTest, SpaceHate) +{ + auto const *const Depends = "no(=1), some(<<1),some (<<1),some( <<1),some(<< 1),some(<<1 ),some(<<1) ,last (=1)"; + const char* const End = Depends + strlen(Depends); + + const char* Start = Depends; + std::string Package; + std::string Version; + unsigned int Op = 29; + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op); + EXPECT_NE(nullptr, Start); + EXPECT_EQ("no", Package); + EXPECT_EQ("1", Version); + EXPECT_EQ(pkgCache::Dep::Equals, Op); + + for (int i = 0; i < 6; ++i) + { + SCOPED_TRACE(i); + Start = debListParser::ParseDepends(Start, End, Package, Version, Op); + EXPECT_NE(nullptr, Start); + EXPECT_EQ("some", Package); + EXPECT_EQ("1", Version); + EXPECT_EQ(pkgCache::Dep::Less, Op); + } + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op); + EXPECT_EQ(End, Start); + EXPECT_EQ("last", Package); + EXPECT_EQ("1", Version); + EXPECT_EQ(pkgCache::Dep::Equals, Op); +} diff --git a/test/libapt/pattern_test.cc b/test/libapt/pattern_test.cc index 55bc4bd..75afead 100644 --- a/test/libapt/pattern_test.cc +++ b/test/libapt/pattern_test.cc @@ -10,7 +10,7 @@ #include #include -#include +#include "common.h" using namespace APT::Internal; diff --git a/test/libapt/priority_test.cc b/test/libapt/priority_test.cc index af7932a..5570340 100644 --- a/test/libapt/priority_test.cc +++ b/test/libapt/priority_test.cc @@ -1,6 +1,6 @@ #include #include -#include +#include "common.h" #include using std::string; diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index f6a1a91..9046b91 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -8,7 +8,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/srvrecs_test.cc b/test/libapt/srvrecs_test.cc index f042579..c20f945 100644 --- a/test/libapt/srvrecs_test.cc +++ b/test/libapt/srvrecs_test.cc @@ -7,7 +7,7 @@ #include #include -#include +#include "common.h" TEST(SrvRecTest, PopFromSrvRecs) { diff --git a/test/libapt/stringview_test.cc b/test/libapt/stringview_test.cc index 9cfaa3b..5abb7a8 100644 --- a/test/libapt/stringview_test.cc +++ b/test/libapt/stringview_test.cc @@ -5,7 +5,7 @@ #include -#include +#include "common.h" TEST(StringViewTest,EmptyString) { diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index 469de44..d7e5736 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -6,7 +6,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/tagfile_test.cc b/test/libapt/tagfile_test.cc index 51a574f..1dad5fe 100644 --- a/test/libapt/tagfile_test.cc +++ b/test/libapt/tagfile_test.cc @@ -9,7 +9,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/tagsection_test.cc b/test/libapt/tagsection_test.cc index 80cecca..28156f7 100644 --- a/test/libapt/tagsection_test.cc +++ b/test/libapt/tagsection_test.cc @@ -6,7 +6,7 @@ #include #include -#include +#include "common.h" #include "file-helpers.h" diff --git a/test/libapt/teestream_test.cc b/test/libapt/teestream_test.cc index a897e08..da85b70 100644 --- a/test/libapt/teestream_test.cc +++ b/test/libapt/teestream_test.cc @@ -5,7 +5,7 @@ #include #include -#include +#include "common.h" TEST(TeeStreamTest,TwoStringSinks) { diff --git a/test/libapt/uri_test.cc b/test/libapt/uri_test.cc index 519de49..dfdff1b 100644 --- a/test/libapt/uri_test.cc +++ b/test/libapt/uri_test.cc @@ -2,7 +2,7 @@ #include #include #include -#include +#include "common.h" #include TEST(URITest, BasicHTTP) -- cgit v1.2.3