Browse Source

Prevent GTest from flooding us with compiler warnings

GTest has a bunch of undefined macros which causes the compiler to spit
out warnings for each one on each test file. There isn't much we can do,
so we just disable the warning for the testcases. Other warnings like
sign-promo and sign-compare we can avoid by being more explicit about
our expected integer constants being unsigned.

As we are just changing testcases, there is no user visible change which
would deserve to be noted in the changelog.

Gbp-Dch: Ignore
Reported-By: gcc-8
tags/debian/1.7.0_alpha0ubuntu2
David Kalnischkies 3 years ago
parent
commit
1d77c91500
20 changed files with 193 additions and 187 deletions
  1. +5
    -0
      test/libapt/CMakeLists.txt
  2. +1
    -1
      test/libapt/authconf_test.cc
  3. +10
    -10
      test/libapt/cdrom_test.cc
  4. +8
    -8
      test/libapt/cdromfindpackages_test.cc
  5. +10
    -10
      test/libapt/commandline_test.cc
  6. +10
    -9
      test/libapt/compareversion_test.cc
  7. +12
    -12
      test/libapt/configuration_test.cc
  8. +7
    -7
      test/libapt/fileutl_test.cc
  9. +8
    -8
      test/libapt/getarchitectures_test.cc
  10. +22
    -22
      test/libapt/getlanguages_test.cc
  11. +7
    -7
      test/libapt/getlistoffilesindir_test.cc
  12. +24
    -24
      test/libapt/hashsums_test.cc
  13. +1
    -1
      test/libapt/install_progress_test.cc
  14. +1
    -1
      test/libapt/sourcelist_test.cc
  15. +3
    -3
      test/libapt/srvrecs_test.cc
  16. +7
    -7
      test/libapt/stringview_test.cc
  17. +12
    -12
      test/libapt/strutil_test.cc
  18. +21
    -21
      test/libapt/tagfile_test.cc
  19. +11
    -11
      test/libapt/tagsection_test.cc
  20. +13
    -13
      test/libapt/uri_test.cc

+ 5
- 0
test/libapt/CMakeLists.txt View File

@@ -22,6 +22,11 @@ if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
endif()

if(GTEST_FOUND)
# gtest produces some warnings with the set of warnings we activate,
# so disable the offending warnings while compiling tests for now
add_optional_compile_options(Wno-undef)
add_optional_compile_options(Wno-ctor-dtor-privacy)

# Definition of the C++ files used to build the test binary - note that this
# is expanded at CMake time, so you have to rerun cmake if you add or remove
# a file (you can just run cmake . in the build directory)


+ 1
- 1
test/libapt/authconf_test.cc View File

@@ -60,7 +60,7 @@ machine example.last/debian login debian password rules)apt");
EXPECT_EQ("apt", U.User);
EXPECT_EQ("apt", U.Password);
EXPECT_EQ("example.org", U.Host);
EXPECT_EQ(90, U.Port);
EXPECT_EQ(90u, U.Port);
EXPECT_EQ("/foo", U.Path);

EXPECT_TRUE(fd.Seek(0));


+ 10
- 10
test/libapt/cdrom_test.cc View File

@@ -32,59 +32,59 @@ TEST(CDROMTest,ReduceSourcelist)

List.push_back(" wheezy main");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(1, R.size());
ASSERT_EQ(1u, R.size());
EXPECT_EQ(" wheezy main", R[0]);

List.push_back(" wheezy main");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(1, R.size());
ASSERT_EQ(1u, R.size());
EXPECT_EQ(" wheezy main", R[0]);

List.push_back(" wheezy contrib");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(1, R.size());
ASSERT_EQ(1u, R.size());
EXPECT_EQ(" wheezy contrib main", R[0]);

List.push_back(" wheezy-update contrib");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(2, R.size());
ASSERT_EQ(2u, R.size());
EXPECT_EQ(" wheezy contrib main", R[0]);
EXPECT_EQ(" wheezy-update contrib", R[1]);

List.push_back(" wheezy-update contrib");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(2, R.size());
ASSERT_EQ(2u, R.size());
EXPECT_EQ(" wheezy contrib main", R[0]);
EXPECT_EQ(" wheezy-update contrib", R[1]);

List.push_back(" wheezy-update non-free");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(2, R.size());
ASSERT_EQ(2u, R.size());
EXPECT_EQ(" wheezy contrib main", R[0]);
EXPECT_EQ(" wheezy-update contrib non-free", R[1]);

List.push_back(" wheezy-update main");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(2, R.size());
ASSERT_EQ(2u, R.size());
EXPECT_EQ(" wheezy contrib main", R[0]);
EXPECT_EQ(" wheezy-update contrib main non-free", R[1]);

List.push_back(" wheezy non-free");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(2, R.size());
ASSERT_EQ(2u, R.size());
EXPECT_EQ(" wheezy contrib main non-free", R[0]);
EXPECT_EQ(" wheezy-update contrib main non-free", R[1]);

List.push_back(" sid main");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(3, R.size());
ASSERT_EQ(3u, R.size());
EXPECT_EQ(" sid main", R[0]);
EXPECT_EQ(" wheezy contrib main non-free", R[1]);
EXPECT_EQ(" wheezy-update contrib main non-free", R[2]);

List.push_back(" sid main-reduce");
R = cd.ReduceSourcelist(CD, List);
ASSERT_EQ(3, R.size());
ASSERT_EQ(3u, R.size());
EXPECT_EQ(" sid main main-reduce", R[0]);
EXPECT_EQ(" wheezy contrib main non-free", R[1]);
EXPECT_EQ(" wheezy-update contrib main non-free", R[2]);


+ 8
- 8
test/libapt/cdromfindpackages_test.cc View File

@@ -76,21 +76,21 @@ TEST(CDROMTest,FindPackages)
std::vector<std::string> Packages, Sources, Signatur, Translation;
std::string InfoDir;
EXPECT_TRUE(cd.FindPackages(path, Packages, Sources, Signatur, Translation, InfoDir));
EXPECT_EQ(5, Packages.size());
EXPECT_EQ(5u, Packages.size());
EXPECT_EQ(path + "/dists/sid/main/binary-i386/", Packages[0]);
EXPECT_EQ(path + "/dists/stable/contrib/binary-amd64/", Packages[1]);
EXPECT_EQ(path + "/dists/stable/main/binary-i386/", Packages[2]);
EXPECT_EQ(path + "/dists/stable/non-free/binary-all/", Packages[3]);
EXPECT_EQ(path + "/dists/unstable/main/binary-i386/", Packages[4]);
EXPECT_EQ(3, Sources.size());
EXPECT_EQ(3u, Sources.size());
EXPECT_EQ(path + "/dists/sid/main/source/", Sources[0]);
EXPECT_EQ(path + "/dists/stable/main/source/", Sources[1]);
EXPECT_EQ(path + "/dists/unstable/main/source/", Sources[2]);
EXPECT_EQ(3, Signatur.size());
EXPECT_EQ(3u, Signatur.size());
EXPECT_EQ(path + "/dists/sid/", Signatur[0]);
EXPECT_EQ(path + "/dists/stable/", Signatur[1]);
EXPECT_EQ(path + "/dists/unstable/", Signatur[2]);
EXPECT_EQ(4, Translation.size());
EXPECT_EQ(4u, Translation.size());
EXPECT_EQ(path + "/dists/sid/main/i18n/Translation-de", Translation[0]);
EXPECT_EQ(path + "/dists/sid/main/i18n/Translation-en", Translation[1]);
EXPECT_EQ(path + "/dists/unstable/main/i18n/Translation-de", Translation[2]);
@@ -106,18 +106,18 @@ TEST(CDROMTest,FindPackages)
_error->DumpErrors();
cd.DropRepeats(Translation, "");

EXPECT_EQ(4, Packages.size());
EXPECT_EQ(4u, Packages.size());
EXPECT_EQ(path + "/dists/stable/contrib/binary-amd64/", Packages[0]);
EXPECT_EQ(path + "/dists/stable/main/binary-i386/", Packages[1]);
EXPECT_EQ(path + "/dists/stable/non-free/binary-all/", Packages[2]);
EXPECT_EQ(path + "/dists/unstable/main/binary-i386/", Packages[3]);
EXPECT_EQ(2, Sources.size());
EXPECT_EQ(2u, Sources.size());
EXPECT_EQ(path + "/dists/stable/main/source/", Sources[0]);
EXPECT_EQ(path + "/dists/unstable/main/source/", Sources[1]);
EXPECT_EQ(2, Signatur.size());
EXPECT_EQ(2u, Signatur.size());
EXPECT_EQ(path + "/dists/stable/", Signatur[0]);
EXPECT_EQ(path + "/dists/unstable/", Signatur[1]);
EXPECT_EQ(2, Translation.size());
EXPECT_EQ(2u, Translation.size());
EXPECT_EQ(path + "/dists/unstable/main/i18n/Translation-de", Translation[0]);
EXPECT_EQ(path + "/dists/unstable/main/i18n/Translation-en", Translation[1]);



+ 10
- 10
test/libapt/commandline_test.cc View File

@@ -73,7 +73,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(3 , argv);
EXPECT_TRUE(c.FindB("Test::Worked", false));
EXPECT_EQ("yes", c.Find("Test::Worked", "no"));
EXPECT_EQ(0, CmdL.FileSize());
EXPECT_EQ(0u, CmdL.FileSize());
}
c.Clear("Test");
{
@@ -81,7 +81,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(2 , argv);
EXPECT_TRUE(c.Exists("Test::Worked"));
EXPECT_EQ("yes", c.Find("Test::Worked", "no"));
EXPECT_EQ(0, CmdL.FileSize());
EXPECT_EQ(0u, CmdL.FileSize());
}
c.Clear("Test");
{
@@ -89,7 +89,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(3 , argv);
EXPECT_TRUE(c.Exists("Test::Worked"));
EXPECT_EQ("no", c.Find("Test::Worked", "no"));
EXPECT_EQ(1, CmdL.FileSize());
EXPECT_EQ(1u, CmdL.FileSize());
}

c.Clear("Test");
@@ -98,7 +98,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(3 , argv);
EXPECT_TRUE(c.FindB("Test::Worked", false));
EXPECT_EQ("yes", c.Find("Test::Worked", "no"));
EXPECT_EQ(0, CmdL.FileSize());
EXPECT_EQ(0u, CmdL.FileSize());
}
c.Clear("Test");
{
@@ -106,7 +106,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(2 , argv);
EXPECT_TRUE(c.Exists("Test::Worked"));
EXPECT_EQ("yes", c.Find("Test::Worked", "no"));
EXPECT_EQ(0, CmdL.FileSize());
EXPECT_EQ(0u, CmdL.FileSize());
}
c.Clear("Test");
{
@@ -114,7 +114,7 @@ TEST(CommandLineTest,Parsing)
CmdL.Parse(3 , argv);
EXPECT_TRUE(c.Exists("Test::Worked"));
EXPECT_EQ("no", c.Find("Test::Worked", "no"));
EXPECT_EQ(1, CmdL.FileSize());
EXPECT_EQ(1u, CmdL.FileSize());
}

c.Clear("Test");
@@ -185,7 +185,7 @@ TEST(CommandLineTest,GetCommand)
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
EXPECT_EQ(c.Find("APT::Default-Release"), "unstable");
EXPECT_TRUE(c.FindB("APT::Get::Download-Only"));
ASSERT_EQ(2, CmdL.FileSize());
ASSERT_EQ(2u, CmdL.FileSize());
EXPECT_EQ(std::string(CmdL.FileList[0]), "remove");
EXPECT_EQ(std::string(CmdL.FileList[1]), "foo");
}
@@ -199,7 +199,7 @@ TEST(CommandLineTest,GetCommand)
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
EXPECT_EQ(c.Find("APT::Default-Release"), "unstable");
EXPECT_FALSE(c.FindB("APT::Get::Download-Only"));
ASSERT_EQ(3, CmdL.FileSize());
ASSERT_EQ(3u, CmdL.FileSize());
EXPECT_EQ(std::string(CmdL.FileList[0]), "remove");
EXPECT_EQ(std::string(CmdL.FileList[1]), "-d");
EXPECT_EQ(std::string(CmdL.FileList[2]), "foo");
@@ -214,7 +214,7 @@ TEST(CommandLineTest,GetCommand)
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
EXPECT_EQ(c.Find("APT::Default-Release"), "unstable");
EXPECT_FALSE(c.FindB("APT::Get::Download-Only"));
ASSERT_EQ(CmdL.FileSize(), 3);
ASSERT_EQ(3u, CmdL.FileSize());
EXPECT_EQ(std::string(CmdL.FileList[0]), "remove");
EXPECT_EQ(std::string(CmdL.FileList[1]), "-d");
EXPECT_EQ(std::string(CmdL.FileList[2]), "foo");
@@ -229,7 +229,7 @@ TEST(CommandLineTest,GetCommand)
ASSERT_TRUE(CmdL.Parse(sizeof(argv)/sizeof(argv[0]), argv));
EXPECT_EQ(c.Find("APT::Default-Release"), "unstable");
EXPECT_FALSE(c.FindB("APT::Get::Download-Only"));
ASSERT_EQ(CmdL.FileSize(), 4);
ASSERT_EQ(4u, CmdL.FileSize());
EXPECT_EQ(std::string(CmdL.FileList[0]), "install");
EXPECT_EQ(std::string(CmdL.FileList[1]), "remove");
EXPECT_EQ(std::string(CmdL.FileList[2]), "-d");


+ 10
- 9
test/libapt/compareversion_test.cc View File

@@ -32,17 +32,18 @@

using namespace std;

static bool callDPKG(const char *val, const char *ref, const char &op) {
static bool callDPKG(const char * const val, const char * const ref, char const * const op) {
pid_t Process = ExecFork();
if (Process == 0)
{
const char * args[6];
args[0] = "/usr/bin/dpkg";
args[1] = "--compare-versions";
args[2] = val;
args[3] = (op == 1) ? ">>" : ( (op == 0) ? "=" : "<<");
args[4] = ref;
args[5] = 0;
const char * args[] = {
BIN_DIR "/dpkg",
"--compare-versions",
val,
op,
ref,
nullptr
};
execv(args[0], (char**) args);
exit(1);
}
@@ -57,7 +58,7 @@ static bool callDPKG(const char *val, const char *ref, const char &op) {
int Res = debVS.CmpVersion(A, B); \
Res = (Res < 0) ? -1 : ( (Res > 0) ? 1 : Res); \
EXPECT_EQ(compare, Res) << "APT: A: »" << A << "« B: »" << B << "«"; \
EXPECT_PRED3(callDPKG, A, B, compare); \
EXPECT_PRED3(callDPKG, A, B, ((compare == 1) ? ">>" : ( (compare == 0) ? "=" : "<<"))); \
}
#define EXPECT_VERSION(A, compare, B) \
EXPECT_VERSION_PART(A, compare, B); \


+ 12
- 12
test/libapt/configuration_test.cc View File

@@ -19,7 +19,7 @@ TEST(ConfigurationTest,Lists)
Cnf.Set("APT::Keep-Fds::2",47);
Cnf.Set("APT::Keep-Fds::","broken");
std::vector<std::string> fds = Cnf.FindVector("APT::Keep-Fds");
ASSERT_EQ(4, fds.size());
ASSERT_EQ(4u, fds.size());
EXPECT_EQ("28", fds[0]);
EXPECT_EQ("17", fds[1]);
EXPECT_EQ("47", fds[2]);
@@ -36,7 +36,7 @@ TEST(ConfigurationTest,Lists)
Cnf.Clear("APT::Keep-Fds::2");
EXPECT_TRUE(Cnf.Exists("APT::Keep-Fds::2"));
fds = Cnf.FindVector("APT::Keep-Fds");
ASSERT_EQ(4, fds.size());
ASSERT_EQ(4u, fds.size());
EXPECT_EQ("28", fds[0]);
EXPECT_EQ("17", fds[1]);
EXPECT_EQ("", fds[2]);
@@ -44,7 +44,7 @@ TEST(ConfigurationTest,Lists)

Cnf.Clear("APT::Keep-Fds",28);
fds = Cnf.FindVector("APT::Keep-Fds");
ASSERT_EQ(3, fds.size());
ASSERT_EQ(3u, fds.size());
EXPECT_EQ("17", fds[0]);
EXPECT_EQ("", fds[1]);
EXPECT_EQ("broken", fds[2]);
@@ -60,7 +60,7 @@ TEST(ConfigurationTest,Lists)
Cnf.Set("APT::Keep-Fds::",21);
Cnf.Set("APT::Keep-Fds::",42);
fds = Cnf.FindVector("APT::Keep-Fds");
ASSERT_EQ(2, fds.size());
ASSERT_EQ(2u, fds.size());
EXPECT_EQ("21", fds[0]);
EXPECT_EQ("42", fds[1]);

@@ -145,30 +145,30 @@ TEST(ConfigurationTest,Vector)
Configuration Cnf;

std::vector<std::string> vec = Cnf.FindVector("Test::Vector", "");
EXPECT_EQ(0, vec.size());
EXPECT_EQ(0u, vec.size());
vec = Cnf.FindVector("Test::Vector", "foo");
ASSERT_EQ(1, vec.size());
ASSERT_EQ(1u, vec.size());
EXPECT_EQ("foo", vec[0]);
vec = Cnf.FindVector("Test::Vector", "foo,bar");
EXPECT_EQ(2, vec.size());
EXPECT_EQ(2u, vec.size());
EXPECT_EQ("foo", vec[0]);
EXPECT_EQ("bar", vec[1]);
Cnf.Set("Test::Vector::", "baz");
Cnf.Set("Test::Vector::", "bob");
Cnf.Set("Test::Vector::", "dob");
vec = Cnf.FindVector("Test::Vector");
ASSERT_EQ(3, vec.size());
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("baz", vec[0]);
EXPECT_EQ("bob", vec[1]);
EXPECT_EQ("dob", vec[2]);
vec = Cnf.FindVector("Test::Vector", "foo,bar");
ASSERT_EQ(3, vec.size());
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("baz", vec[0]);
EXPECT_EQ("bob", vec[1]);
EXPECT_EQ("dob", vec[2]);
Cnf.Set("Test::Vector", "abel,bravo");
vec = Cnf.FindVector("Test::Vector", "foo,bar");
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("abel", vec[0]);
EXPECT_EQ("bravo", vec[1]);
}
@@ -220,12 +220,12 @@ List::Option2 { "Multi";
EXPECT_EQ(42, Cnf.FindI("Answer::Simple"));
EXPECT_TRUE(Cnf.Exists("List::Option"));
auto const singleline = Cnf.FindVector("List::Option");
EXPECT_EQ(3, singleline.size());
EXPECT_EQ(3u, singleline.size());
EXPECT_EQ("In", singleline[0]);
EXPECT_EQ("One", singleline[1]);
EXPECT_EQ("Line", singleline[2]);
auto const multiline = Cnf.FindVector("List::Option2");
EXPECT_EQ(3, multiline.size());
EXPECT_EQ(3u, multiline.size());
EXPECT_EQ("Multi", multiline[0]);
EXPECT_EQ("Line", multiline[1]);
EXPECT_EQ("Options", multiline[2]);


+ 7
- 7
test/libapt/fileutl_test.cc View File

@@ -49,7 +49,7 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission
EXPECT_TRUE(f.IsOpen());
EXPECT_FALSE(f.Failed());
EXPECT_FALSE(f.Eof());
EXPECT_NE(0, f.FileSize());
EXPECT_NE(0u, f.FileSize());
EXPECT_FALSE(f.Failed());
EXPECT_NE(0, f.ModificationTime());
EXPECT_FALSE(f.Failed());
@@ -96,7 +96,7 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission
EXPECT_FALSE(f.Failed());
EXPECT_FALSE(f.Eof());
EXPECT_N_STR(expect, readback);
EXPECT_EQ(7, f.Tell());
EXPECT_EQ(7u, f.Tell());
}
{
APT_INIT_READBACK
@@ -180,7 +180,7 @@ static void TestFileFd(mode_t const a_umask, mode_t const ExpectedFilePermission
static void TestFileFd(unsigned int const filemode)
{
auto const compressors = APT::Configuration::getCompressors();
EXPECT_EQ(8, compressors.size());
EXPECT_EQ(8u, compressors.size());
bool atLeastOneWasTested = false;
for (auto const &c: compressors)
{
@@ -204,7 +204,7 @@ TEST(FileUtlTest, FileFD)
_config->Set("APT::Compressor::rev::Binary", "rev");
_config->Set("APT::Compressor::rev::Cost", 10);
auto const compressors = APT::Configuration::getCompressors(false);
EXPECT_EQ(8, compressors.size());
EXPECT_EQ(8u, compressors.size());
EXPECT_TRUE(std::any_of(compressors.begin(), compressors.end(), [](APT::Configuration::Compressor const &c) { return c.Name == "rev"; }));

std::string const startdir = SafeGetCWD();
@@ -232,7 +232,7 @@ TEST(FileUtlTest, Glob)
std::vector<std::string> files;
// normal match
files = Glob("*MakeLists.txt");
EXPECT_EQ(1, files.size());
EXPECT_EQ(1u, files.size());

// not there
files = Glob("xxxyyyzzz");
@@ -241,7 +241,7 @@ TEST(FileUtlTest, Glob)

// many matches (number is a bit random)
files = Glob("*.cc");
EXPECT_LT(10, files.size());
EXPECT_LT(10u, files.size());
}
TEST(FileUtlTest, GetTempDir)
{
@@ -296,7 +296,7 @@ TEST(FileUtlTest, Popen)
EXPECT_TRUE(Popen(Args, Fd, Child, FileFd::ReadOnly));
EXPECT_TRUE(Fd.Read(buf, sizeof(buf)-1, &n));
buf[n] = 0;
EXPECT_NE(n, 0);
EXPECT_NE(n, 0u);
EXPECT_STREQ(buf, "meepmeep\n");

// wait for the child to exit and cleanup


+ 8
- 8
test/libapt/getarchitectures_test.cc View File

@@ -16,36 +16,36 @@ TEST(ArchitecturesTest,SimpleLists)
_config->Set("APT::Architectures::1", "i386");
_config->Set("APT::Architectures::2", "amd64");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);

_config->Set("APT::Architecture", "i386");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);

_config->Set("APT::Architectures::2", "");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(1, vec.size());
ASSERT_EQ(1u, vec.size());
EXPECT_EQ("i386", vec[0]);

_config->Set("APT::Architecture", "armel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("armel", vec[0]);
EXPECT_EQ("i386", vec[1]);

_config->Set("APT::Architectures::2", "armel");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("armel", vec[1]);

_config->Set("APT::Architectures", "armel,armhf");
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("armel", vec[0]);
EXPECT_EQ("armhf", vec[1]);
_config->Clear();
@@ -66,9 +66,9 @@ TEST(ArchitecturesTest,Duplicates)
_config->Set("APT::Architectures::", "amd64");
_config->Set("APT::Architectures::", "amd64");
std::vector<std::string> vec = _config->FindVector("APT::Architectures");
ASSERT_EQ(10, vec.size());
ASSERT_EQ(10u, vec.size());
vec = APT::Configuration::getArchitectures(false);
ASSERT_EQ(3, vec.size());
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("i386", vec[0]);
EXPECT_EQ("amd64", vec[1]);
EXPECT_EQ("armel", vec[2]);


+ 22
- 22
test/libapt/getlanguages_test.cc View File

@@ -27,7 +27,7 @@ TEST(LanguagesTest,Environment)
env[1] = "";

std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, env);
ASSERT_EQ(3 ,vec.size());
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -35,27 +35,27 @@ TEST(LanguagesTest,Environment)
// Special: Check if the cache is actually in use
env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, true, env);
ASSERT_EQ(3, vec.size());
ASSERT_EQ(3u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);

env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("en_GB", vec[0]);
EXPECT_EQ("en", vec[1]);

// esperanto
env[0] = "eo.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
ASSERT_EQ(2, vec.size());
ASSERT_EQ(2u, vec.size());
EXPECT_EQ("eo", vec[0]);
EXPECT_EQ("en", vec[1]);

env[0] = "tr_DE@euro";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("tr_DE", vec[0]);
EXPECT_EQ("tr", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -63,7 +63,7 @@ TEST(LanguagesTest,Environment)
env[0] = "de_NO";
env[1] = "de_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(6, vec.size());
EXPECT_EQ(6u, vec.size());
EXPECT_EQ("de_NO", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en_GB", vec[2]);
@@ -74,21 +74,21 @@ TEST(LanguagesTest,Environment)
env[0] = "pt_PR.UTF-8";
env[1] = "";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("pt_PR", vec[0]);
EXPECT_EQ("pt", vec[1]);
EXPECT_EQ("en", vec[2]);

env[0] = "ast_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env); // bogus, but syntactical correct
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("ast_DE", vec[0]);
EXPECT_EQ("ast", vec[1]);
EXPECT_EQ("en", vec[2]);

env[0] = "C";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("en", vec[0]);

_config->Set("Acquire::Languages", "none");
@@ -99,25 +99,25 @@ TEST(LanguagesTest,Environment)
_config->Set("Acquire::Languages", "environment");
env[0] = "C";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("en", vec[0]);

_config->Set("Acquire::Languages", "de");
env[0] = "C";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("de", vec[0]);

_config->Set("Acquire::Languages", "fr");
env[0] = "ast_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("fr", vec[0]);

_config->Set("Acquire::Languages", "environment,en");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -127,7 +127,7 @@ TEST(LanguagesTest,Environment)
_config->Set("Acquire::Languages::2", "en");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -135,7 +135,7 @@ TEST(LanguagesTest,Environment)
_config->Set("Acquire::Languages::3", "de");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(3, vec.size());
EXPECT_EQ(3u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -169,7 +169,7 @@ TEST(LanguagesTest,TranslationFiles)

_config->Set("Dir::State::lists", tempdir);
std::vector<std::string> vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(8, vec.size());
EXPECT_EQ(8u, vec.size());
EXPECT_EQ("de_DE", vec[0]);
EXPECT_EQ("de", vec[1]);
EXPECT_EQ("en", vec[2]);
@@ -187,7 +187,7 @@ TEST(LanguagesTest,TranslationFiles)

_config->Set("Acquire::Languages", "none");
vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("none", vec[0]);
_config->Set("Acquire::Languages", "");

@@ -198,7 +198,7 @@ TEST(LanguagesTest,TranslationFiles)
EXPECT_TRUE(vec.empty());
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(2, vec.size());
EXPECT_EQ(2u, vec.size());
EXPECT_EQ("en", vec[0]);
EXPECT_EQ("de", vec[1]);

@@ -206,13 +206,13 @@ TEST(LanguagesTest,TranslationFiles)
_config->Set("Acquire::Languages", "de_DE");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("de_DE", vec[0]);

_config->Set("Acquire::Languages", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("none", vec[0]);

_error->PushToStack();
@@ -221,13 +221,13 @@ TEST(LanguagesTest,TranslationFiles)
_config->Set("APT::Acquire::Translation", "ast_DE");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(2, vec.size());
EXPECT_EQ(2u, vec.size());
EXPECT_EQ("ast_DE", vec[0]);
EXPECT_EQ("en", vec[1]);
_config->Set("APT::Acquire::Translation", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
EXPECT_EQ(1, vec.size());
EXPECT_EQ(1u, vec.size());
EXPECT_EQ("en", vec[0]);

// discard the deprecation warning for APT::Acquire::Translation


+ 7
- 7
test/libapt/getlistoffilesindir_test.cc View File

@@ -52,13 +52,13 @@ TEST(FileUtlTest,GetListOfFilesInDir)
// Files with no extension
_error->PushToStack();
std::vector<std::string> files = GetListOfFilesInDir(tempdir, "", true);
ASSERT_EQ(2, files.size());
ASSERT_EQ(2u, files.size());
EXPECT_EQ(P("01yet-anothernormalfile"), files[0]);
EXPECT_EQ(P("anormalfile"), files[1]);

// Files with no extension - should be the same as above
files = GetListOfFilesInDir(tempdir, "", true, true);
ASSERT_EQ(2, files.size());
ASSERT_EQ(2u, files.size());
EXPECT_EQ(P("01yet-anothernormalfile"), files[0]);
EXPECT_EQ(P("anormalfile"), files[1]);

@@ -68,13 +68,13 @@ TEST(FileUtlTest,GetListOfFilesInDir)

// Files with impossible or no extension
files = GetListOfFilesInDir(tempdir, "impossible", true, true);
ASSERT_EQ(2, files.size());
ASSERT_EQ(2u, files.size());
EXPECT_EQ(P("01yet-anothernormalfile"), files[0]);
EXPECT_EQ(P("anormalfile"), files[1]);

// Files with list extension - nothing more
files = GetListOfFilesInDir(tempdir, "list", true);
ASSERT_EQ(4, files.size());
ASSERT_EQ(4u, files.size());
EXPECT_EQ(P("01yet-anotherapt.list"), files[0]);
EXPECT_EQ(P("anormalapt.list"), files[1]);
EXPECT_EQ(P("linkedfile.list"), files[2]);
@@ -82,7 +82,7 @@ TEST(FileUtlTest,GetListOfFilesInDir)

// Files with conf or no extension
files = GetListOfFilesInDir(tempdir, "conf", true, true);
ASSERT_EQ(5, files.size());
ASSERT_EQ(5u, files.size());
EXPECT_EQ(P("01yet-anotherapt.conf"), files[0]);
EXPECT_EQ(P("01yet-anothernormalfile"), files[1]);
EXPECT_EQ(P("anormalapt.conf"), files[2]);
@@ -91,14 +91,14 @@ TEST(FileUtlTest,GetListOfFilesInDir)

// Files with disabled extension - nothing more
files = GetListOfFilesInDir(tempdir, "disabled", true);
ASSERT_EQ(3, files.size());
ASSERT_EQ(3u, files.size());
EXPECT_EQ(P("disabledfile.conf.disabled"), files[0]);
EXPECT_EQ(P("disabledfile.disabled"), files[1]);
EXPECT_EQ(P("disabledfile.list.disabled"), files[2]);

// Files with disabled or no extension
files = GetListOfFilesInDir(tempdir, "disabled", true, true);
ASSERT_EQ(5, files.size());
ASSERT_EQ(5u, files.size());
EXPECT_EQ(P("01yet-anothernormalfile"), files[0]);
EXPECT_EQ(P("anormalfile"), files[1]);
EXPECT_EQ(P("disabledfile.conf.disabled"), files[2]);


+ 24
- 24
test/libapt/hashsums_test.cc View File

@@ -121,7 +121,7 @@ static void getSummationString(char const * const type, std::string &sum)
ASSERT_TRUE(fd.IsOpen());
FileFd input("/etc/os-release", FileFd::ReadOnly);
ASSERT_TRUE(input.IsOpen());
ASSERT_NE(0, input.FileSize());
ASSERT_NE(0u, input.FileSize());
ASSERT_TRUE(CopyFile(input, fd));
ASSERT_TRUE(input.IsOpen());
ASSERT_TRUE(fd.IsOpen());
@@ -130,7 +130,7 @@ static void getSummationString(char const * const type, std::string &sum)
fd.Close();
ASSERT_TRUE(fd.Open(tempfile, FileFd::ReadOnly, FileFd::None));
ASSERT_TRUE(fd.IsOpen());
ASSERT_NE(0, fd.FileSize());
ASSERT_NE(0u, fd.FileSize());
ASSERT_FALSE(fd.Failed());
unlink(tempfile);
free(tempfile);
@@ -171,7 +171,7 @@ TEST(HashSumsTest, FileBased)
hashes.AddFD(fd.Fd());
HashStringList list = hashes.GetHashStringList();
EXPECT_FALSE(list.empty());
EXPECT_EQ(5, list.size());
EXPECT_EQ(5u, list.size());
EXPECT_EQ(md5.Value(), list.find("MD5Sum")->HashValue());
EXPECT_EQ(sha1.Value(), list.find("SHA1")->HashValue());
EXPECT_EQ(sha256.Value(), list.find("SHA256")->HashValue());
@@ -185,7 +185,7 @@ TEST(HashSumsTest, FileBased)
hashes.AddFD(fd.Fd(), sz);
HashStringList list = hashes.GetHashStringList();
EXPECT_FALSE(list.empty());
EXPECT_EQ(5, list.size());
EXPECT_EQ(5u, list.size());
EXPECT_EQ(md5.Value(), list.find("MD5Sum")->HashValue());
EXPECT_EQ(sha1.Value(), list.find("SHA1")->HashValue());
EXPECT_EQ(sha256.Value(), list.find("SHA256")->HashValue());
@@ -198,7 +198,7 @@ TEST(HashSumsTest, FileBased)
hashes.AddFD(fd);
HashStringList list = hashes.GetHashStringList();
EXPECT_FALSE(list.empty());
EXPECT_EQ(3, list.size());
EXPECT_EQ(3u, list.size());
EXPECT_EQ(md5.Value(), list.find("MD5Sum")->HashValue());
EXPECT_EQ(NULL, list.find("SHA1"));
EXPECT_EQ(NULL, list.find("SHA256"));
@@ -209,7 +209,7 @@ TEST(HashSumsTest, FileBased)
hashes2.AddFD(fd);
list = hashes2.GetHashStringList();
EXPECT_FALSE(list.empty());
EXPECT_EQ(3, list.size());
EXPECT_EQ(3u, list.size());
EXPECT_EQ(md5.Value(), list.find("MD5Sum")->HashValue());
EXPECT_EQ(NULL, list.find("SHA1"));
EXPECT_EQ(NULL, list.find("SHA256"));
@@ -263,7 +263,7 @@ TEST(HashSumsTest, FileBased)
EXPECT_TRUE(hashes.empty());
EXPECT_TRUE(hashes.push_back(sha2file));
EXPECT_FALSE(hashes.empty());
EXPECT_EQ(1, hashes.size());
EXPECT_EQ(1u, hashes.size());

HashStringList wrong;
EXPECT_TRUE(wrong.push_back(sha2wrong));
@@ -278,11 +278,11 @@ TEST(HashSumsTest, FileBased)
EXPECT_TRUE(similar != hashes);

EXPECT_TRUE(hashes.push_back(sha2big));
EXPECT_EQ(2, hashes.size());
EXPECT_EQ(2u, hashes.size());
EXPECT_TRUE(hashes.push_back(sha2small));
EXPECT_EQ(2, hashes.size());
EXPECT_EQ(2u, hashes.size());
EXPECT_FALSE(hashes.push_back(sha2wrong));
EXPECT_EQ(2, hashes.size());
EXPECT_EQ(2u, hashes.size());
EXPECT_TRUE(hashes.VerifyFile("/etc/os-release"));

EXPECT_EQ(similar, hashes);
@@ -290,7 +290,7 @@ TEST(HashSumsTest, FileBased)
EXPECT_FALSE(similar != hashes);
similar.clear();
EXPECT_TRUE(similar.empty());
EXPECT_EQ(0, similar.size());
EXPECT_EQ(0u, similar.size());
EXPECT_NE(similar, hashes);
EXPECT_FALSE(similar == hashes);
EXPECT_TRUE(similar != hashes);
@@ -302,13 +302,13 @@ TEST(HashSumsTest, HashStringList)
HashStringList list;
EXPECT_TRUE(list.empty());
EXPECT_FALSE(list.usable());
EXPECT_EQ(0, list.size());
EXPECT_EQ(0u, list.size());
EXPECT_EQ(NULL, list.find(NULL));
EXPECT_EQ(NULL, list.find(""));
EXPECT_EQ(NULL, list.find("MD5Sum"));
EXPECT_EQ(NULL, list.find("ROT26"));
EXPECT_EQ(NULL, list.find("SHA1"));
EXPECT_EQ(0, list.FileSize());
EXPECT_EQ(0u, list.FileSize());

// empty lists aren't equal
HashStringList list2;
@@ -319,24 +319,24 @@ TEST(HashSumsTest, HashStringList)
list.push_back(HashString("Checksum-FileSize", "29"));
EXPECT_FALSE(list.empty());
EXPECT_FALSE(list.usable());
EXPECT_EQ(1, list.size());
EXPECT_EQ(29, list.FileSize());
EXPECT_EQ(1u, list.size());
EXPECT_EQ(29u, list.FileSize());
list.push_back(HashString("MD5Sum", "d41d8cd98f00b204e9800998ecf8427e"));
EXPECT_FALSE(list.empty());
EXPECT_FALSE(list.usable());
EXPECT_EQ(2, list.size());
EXPECT_EQ(29, list.FileSize());
EXPECT_EQ(2u, list.size());
EXPECT_EQ(29u, list.FileSize());
EXPECT_TRUE(NULL != list.find("MD5Sum"));
list.push_back(HashString("SHA1", "cacecbd74968bc90ea3342767e6b94f46ddbcafc"));
EXPECT_FALSE(list.usable());
EXPECT_EQ(3, list.size());
EXPECT_EQ(29, list.FileSize());
EXPECT_EQ(3u, list.size());
EXPECT_EQ(29u, list.FileSize());
EXPECT_TRUE(NULL != list.find("MD5Sum"));
EXPECT_TRUE(NULL != list.find("SHA1"));
list.push_back(HashString("SHA256", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
EXPECT_TRUE(list.usable());
EXPECT_EQ(4, list.size());
EXPECT_EQ(29, list.FileSize());
EXPECT_EQ(4u, list.size());
EXPECT_EQ(29u, list.FileSize());
EXPECT_TRUE(NULL != list.find("MD5Sum"));
EXPECT_TRUE(NULL != list.find("SHA1"));
EXPECT_TRUE(NULL != list.find("SHA256"));
@@ -346,7 +346,7 @@ TEST(HashSumsTest, HashStringList)
list = hashes.GetHashStringList();
EXPECT_FALSE(list.empty());
EXPECT_TRUE(list.usable());
EXPECT_EQ(5, list.size());
EXPECT_EQ(5u, list.size());
EXPECT_TRUE(NULL != list.find(NULL));
EXPECT_TRUE(NULL != list.find(""));
EXPECT_TRUE(NULL != list.find("MD5Sum"));
@@ -356,7 +356,7 @@ TEST(HashSumsTest, HashStringList)
_config->Set("Acquire::ForceHash", "MD5Sum");
EXPECT_FALSE(list.empty());
EXPECT_TRUE(list.usable());
EXPECT_EQ(5, list.size());
EXPECT_EQ(5u, list.size());
EXPECT_TRUE(NULL != list.find(NULL));
EXPECT_TRUE(NULL != list.find(""));
EXPECT_TRUE(NULL != list.find("MD5Sum"));
@@ -366,7 +366,7 @@ TEST(HashSumsTest, HashStringList)
_config->Set("Acquire::ForceHash", "ROT26");
EXPECT_FALSE(list.empty());
EXPECT_FALSE(list.usable());
EXPECT_EQ(5, list.size());
EXPECT_EQ(5u, list.size());
EXPECT_TRUE(NULL == list.find(NULL));
EXPECT_TRUE(NULL == list.find(""));
EXPECT_TRUE(NULL != list.find("MD5Sum"));


+ 1
- 1
test/libapt/install_progress_test.cc View File

@@ -10,7 +10,7 @@ TEST(InstallProgressTest, FancyGetTextProgressStr)
{
APT::Progress::PackageManagerFancy p;

EXPECT_EQ(60, p.GetTextProgressStr(0.5, 60).size());
EXPECT_EQ(60u, p.GetTextProgressStr(0.5, 60).size());
EXPECT_EQ("[#.]", p.GetTextProgressStr(0.5, 4));
EXPECT_EQ("[..........]", p.GetTextProgressStr(0.0, 12));
EXPECT_EQ("[#.........]", p.GetTextProgressStr(0.1, 12));


+ 1
- 1
test/libapt/sourcelist_test.cc View File

@@ -32,7 +32,7 @@ TEST(SourceListTest,ParseFileDeb822)

pkgSourceList sources;
EXPECT_EQ(true, sources.Read(tempfile));
EXPECT_EQ(2, sources.size());
EXPECT_EQ(2u, sources.size());

if (tempfile.empty() == false)
unlink(tempfile.c_str());


+ 3
- 3
test/libapt/srvrecs_test.cc View File

@@ -16,16 +16,16 @@ TEST(SrvRecTest, PopFromSrvRecs)
Meep.emplace_back("bar", 20, 0, 80);
Meep.emplace_back("baz", 30, 0, 80);

EXPECT_EQ(Meep.size(), 3);
EXPECT_EQ(Meep.size(), 3u);
SrvRec const result = PopFromSrvRecs(Meep);
// ensure that pop removed one element
EXPECT_EQ(Meep.size(), 2);
EXPECT_EQ(Meep.size(), 2u);
EXPECT_NE(result.target, "baz");

SrvRec const result2 = PopFromSrvRecs(Meep);
EXPECT_NE(result.target, result2.target);
EXPECT_NE(result2.target, "baz");
EXPECT_EQ(Meep.size(), 1);
EXPECT_EQ(Meep.size(), 1u);

SrvRec const result3 = PopFromSrvRecs(Meep);
EXPECT_EQ(result3.target, "baz");


+ 7
- 7
test/libapt/stringview_test.cc View File

@@ -16,17 +16,17 @@ TEST(StringViewTest,EmptyString)
static_assert( 0 == defString.length(), "def right size");

APT::StringView strString{std::string{}};
EXPECT_EQ(0, strString.length());
EXPECT_EQ(0u, strString.length());

constexpr char const * const charp = "";
constexpr APT::StringView charpString{charp, 0};
static_assert( 0 == charpString.length(), "charp right size");

APT::StringView charp2String{charp};
EXPECT_EQ(0, strString.length());
EXPECT_EQ(0u, strString.length());

const APT::StringView charaString{""};
EXPECT_EQ(0, charaString.length());
EXPECT_EQ(0u, charaString.length());

EXPECT_TRUE(APT::StringView("") == "");
EXPECT_FALSE(APT::StringView("") != "");
@@ -39,22 +39,22 @@ TEST(StringViewTest,FooString)
EXPECT_EQ(0, defString.to_string().compare(0, defString.length(), defString.data(), 3));

APT::StringView strString{std::string{"foo"}};
EXPECT_EQ(3, strString.length());
EXPECT_EQ(3u, strString.length());
EXPECT_EQ(0, strString.to_string().compare(0, strString.length(), strString.data(), 3));

constexpr char const * const charp = "fooGARBAGE";
constexpr APT::StringView charpString{charp, 3};
EXPECT_EQ(3, charpString.length());
EXPECT_EQ(3u, charpString.length());
EXPECT_EQ(0, charpString.to_string().compare(0, charpString.length(), charpString.data(), 3));

char * charp2 = strdup("foo");
APT::StringView charp2String{charp2};
EXPECT_EQ(3, charp2String.length());
EXPECT_EQ(3u, charp2String.length());
EXPECT_EQ(0, charp2String.to_string().compare(0, charp2String.length(), charp2String.data(), 3));
free(charp2);

const APT::StringView charaString{"foo"};
EXPECT_EQ(3, charaString.length());
EXPECT_EQ(3u, charaString.length());
EXPECT_EQ(0, charaString.to_string().compare(0, charaString.length(), charaString.data(), 3));

EXPECT_TRUE(APT::StringView("foo") == "foo");


+ 12
- 12
test/libapt/strutil_test.cc View File

@@ -40,21 +40,21 @@ TEST(StrUtilTest,StringStrip)
TEST(StrUtilTest,StringSplitBasic)
{
std::vector<std::string> result = StringSplit("", "");
EXPECT_EQ(result.size(), 0);
EXPECT_TRUE(result.empty());

result = StringSplit("abc", "");
EXPECT_EQ(result.size(), 0);
EXPECT_TRUE(result.empty());

result = StringSplit("", "abc");
EXPECT_EQ(result.size(), 1);
EXPECT_EQ(result.size(), 1u);

result = StringSplit("abc", "b");
ASSERT_EQ(result.size(), 2);
ASSERT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "a");
EXPECT_EQ(result[1], "c");

result = StringSplit("abc", "abc");
ASSERT_EQ(result.size(), 2);
ASSERT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "");
EXPECT_EQ(result[1], "");
}
@@ -62,20 +62,20 @@ TEST(StrUtilTest,StringSplitDpkgStatus)
{
std::string const input = "status: libnet1:amd64: unpacked";
std::vector<std::string> result = StringSplit(input, "xxx");
ASSERT_EQ(result.size(), 1);
ASSERT_EQ(result.size(), 1u);
EXPECT_EQ(result[0], input);

result = StringSplit(input, "");
EXPECT_EQ(result.size(), 0);
EXPECT_TRUE(result.empty());

result = StringSplit(input, ": ");
ASSERT_EQ(result.size(), 3);
ASSERT_EQ(result.size(), 3u);
EXPECT_EQ(result[0], "status");
EXPECT_EQ(result[1], "libnet1:amd64");
EXPECT_EQ(result[2], "unpacked");

result = StringSplit("x:y:z", ":", 2);
ASSERT_EQ(result.size(), 2);
ASSERT_EQ(result.size(), 2u);
EXPECT_EQ(result[0], "x");
EXPECT_EQ(result[1], "y:z");
}
@@ -190,7 +190,7 @@ static void ReadMessagesTestWithNewLine(char const * const nl, char const * cons
createTemporaryFile("readmessage", fd, NULL, (pkgA + nl + pkgB + nl + pkgC + nl).c_str());
std::vector<std::string> list;
EXPECT_TRUE(ReadMessages(fd.Fd(), list));
EXPECT_EQ(3, list.size());
EXPECT_EQ(3u, list.size());
EXPECT_EQ(pkgA, list[0]);
EXPECT_EQ(pkgB, list[1]);
EXPECT_EQ(pkgC, list[2]);
@@ -210,7 +210,7 @@ static void ReadMessagesTestWithNewLine(char const * const nl, char const * cons
fd.Seek(0);
list.clear();
EXPECT_TRUE(ReadMessages(fd.Fd(), list));
EXPECT_EQ(1, list.size());
EXPECT_EQ(1u, list.size());
EXPECT_EQ((msgsize + i) * strlen(ab), list[0].length());
EXPECT_EQ(std::string::npos, list[0].find_first_not_of(ab));
}
@@ -220,7 +220,7 @@ static void ReadMessagesTestWithNewLine(char const * const nl, char const * cons
fd.Write(nl, strlen(nl));
fd.Seek(0);
EXPECT_TRUE(ReadMessages(fd.Fd(), list));
EXPECT_EQ(2, list.size());
EXPECT_EQ(2u, list.size());
EXPECT_EQ((msgsize + 20) * strlen(ab), list[0].length());
EXPECT_EQ(std::string::npos, list[0].find_first_not_of(ab));
EXPECT_EQ(pkgA, list[1]);


+ 21
- 21
test/libapt/tagfile_test.cc View File

@@ -23,7 +23,7 @@ TEST(TagFileTest,SingleField)
ASSERT_TRUE(tfile.Step(section));

// It has one field
EXPECT_EQ(1, section.Count());
EXPECT_EQ(1u, section.Count());
// ... and it is called FieldA-12345678
EXPECT_TRUE(section.Exists("FieldA-12345678"));
// its value is correct
@@ -37,13 +37,13 @@ TEST(TagFileTest,SingleField)

// Now we scan an empty section to test reset
ASSERT_TRUE(section.Scan("\n\n", 2, true));
EXPECT_EQ(0, section.Count());
EXPECT_EQ(0u, section.Count());
EXPECT_FALSE(section.Exists("FieldA-12345678"));
EXPECT_FALSE(section.Exists("FieldB-12345678"));

createTemporaryFile("emptyfile", fd, NULL, NULL);
ASSERT_FALSE(tfile.Step(section));
EXPECT_EQ(0, section.Count());
EXPECT_EQ(0u, section.Count());
}

TEST(TagFileTest,MultipleSections)
@@ -72,7 +72,7 @@ TEST(TagFileTest,MultipleSections)
EXPECT_FALSE(section.Exists("Version"));

EXPECT_TRUE(tfile.Step(section));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
EXPECT_TRUE(section.Exists("Version"));
EXPECT_TRUE(section.Exists("Package"));
EXPECT_TRUE(section.Exists("Size"));
@@ -80,19 +80,19 @@ TEST(TagFileTest,MultipleSections)
EXPECT_TRUE(section.Exists("Description"));
EXPECT_EQ("pkgA", section.FindS("Package"));
EXPECT_EQ("1", section.FindS("Version"));
EXPECT_EQ(1, section.FindULL("Version"));
EXPECT_EQ(100, section.FindULL("Size"));
EXPECT_EQ(1u, section.FindULL("Version"));
EXPECT_EQ(100u, section.FindULL("Size"));
unsigned long Flags = 1;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(1, Flags);
EXPECT_EQ(1u, Flags);
Flags = 0;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(0, Flags);
EXPECT_EQ(0u, Flags);
EXPECT_EQ("aaa\n aaa", section.FindS("Description"));


EXPECT_TRUE(tfile.Step(section));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
EXPECT_TRUE(section.Exists("Version"));
EXPECT_TRUE(section.Exists("Package"));
EXPECT_FALSE(section.Exists("Size"));
@@ -100,18 +100,18 @@ TEST(TagFileTest,MultipleSections)
EXPECT_TRUE(section.Exists("Description"));
EXPECT_EQ("pkgB", section.FindS("Package"));
EXPECT_EQ("1", section.FindS("Version"));
EXPECT_EQ(1, section.FindULL("Version"));
EXPECT_EQ(0, section.FindULL("Size"));
EXPECT_EQ(1u, section.FindULL("Version"));
EXPECT_EQ(0u, section.FindULL("Size"));
Flags = 1;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(0, Flags);
EXPECT_EQ(0u, Flags);
Flags = 0;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(0, Flags);
EXPECT_EQ(0u, Flags);
EXPECT_EQ("bbb", section.FindS("Description"));

EXPECT_TRUE(tfile.Step(section));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
EXPECT_TRUE(section.Exists("Version"));
EXPECT_TRUE(section.Exists("Package"));
EXPECT_FALSE(section.Exists("Size"));
@@ -119,13 +119,13 @@ TEST(TagFileTest,MultipleSections)
EXPECT_TRUE(section.Exists("Description"));
EXPECT_EQ("pkgC", section.FindS("Package"));
EXPECT_EQ("2", section.FindS("Version"));
EXPECT_EQ(2, section.FindULL("Version"));
EXPECT_EQ(2u, section.FindULL("Version"));
Flags = 0;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(1, Flags);
EXPECT_EQ(1u, Flags);
Flags = 1;
EXPECT_TRUE(section.FindFlag("Flag", Flags, 1));
EXPECT_EQ(1, Flags);
EXPECT_EQ(1u, Flags);
EXPECT_EQ("ccc", section.FindS("Description"));

// There is no section left in this tag file
@@ -152,7 +152,7 @@ TEST(TagFileTest,BigSection)
std::stringstream name;
name << "Field-" << i;
EXPECT_TRUE(section.Exists(name.str().c_str())) << name.str() << " does not exist";
EXPECT_EQ((2000 + i), section.FindULL(name.str().c_str()));
EXPECT_EQ((i + 2000), section.FindULL(name.str().c_str()));
}

// There is only one section in this tag file
@@ -170,7 +170,7 @@ TEST(TagFileTest, PickedUpFromPreviousCall)

pkgTagSection section;
EXPECT_FALSE(section.Scan(content.c_str(), content.size()/2));
EXPECT_NE(0, section.Count());
EXPECT_NE(0u, section.Count());
EXPECT_NE(count, section.Count());
EXPECT_TRUE(section.Scan(content.c_str(), content.size(), false));
EXPECT_EQ(count, section.Count());
@@ -180,7 +180,7 @@ TEST(TagFileTest, PickedUpFromPreviousCall)
std::stringstream name;
name << "Field-" << i;
EXPECT_TRUE(section.Exists(name.str().c_str())) << name.str() << " does not exist";
EXPECT_EQ((2000 + i), section.FindULL(name.str().c_str()));
EXPECT_EQ((i + 2000), section.FindULL(name.str().c_str()));
}
}

@@ -224,7 +224,7 @@ TEST(TagFileTest, SpacesEverywhere)
EXPECT_EQ("yes", section.FindS("Naming Spaces"));
EXPECT_EQ(":yes:", section.FindS("Multi-Colon"));
// overridden values are still present, but not really accessible
EXPECT_EQ(12, section.Count());
EXPECT_EQ(12u, section.Count());
}

TEST(TagFileTest, Comments)


+ 11
- 11
test/libapt/tagsection_test.cc View File

@@ -43,7 +43,7 @@ static void setupTestcaseStart(FileFd &fd, pkgTagSection &section, std::string &
EXPECT_EQ(typoRawValue, section.FindRawS("TypoA"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteUnmodified)
{
@@ -64,7 +64,7 @@ TEST(TagSectionTest,WriteUnmodified)
EXPECT_EQ(typoValue, section.FindS("TypoA"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteUnmodifiedOrder)
{
@@ -86,7 +86,7 @@ TEST(TagSectionTest,WriteUnmodifiedOrder)
EXPECT_EQ(typoValue, section.FindS("TypoA"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteUnmodifiedOrderReversed)
{
@@ -108,7 +108,7 @@ TEST(TagSectionTest,WriteUnmodifiedOrderReversed)
EXPECT_EQ(typoValue, section.FindS("TypoA"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteUnmodifiedOrderNotAll)
{
@@ -130,7 +130,7 @@ TEST(TagSectionTest,WriteUnmodifiedOrderNotAll)
EXPECT_EQ(typoValue, section.FindS("TypoA"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteNoOrderRename)
{
@@ -153,7 +153,7 @@ TEST(TagSectionTest,WriteNoOrderRename)
EXPECT_EQ(typoValue, section.FindS("TypoB"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteNoOrderRemove)
{
@@ -174,7 +174,7 @@ TEST(TagSectionTest,WriteNoOrderRemove)
EXPECT_FALSE(section.Exists("Override"));
EXPECT_TRUE(section.Exists("Override-Backup"));
EXPECT_EQ(packageValue, section.FindS("Package"));
EXPECT_EQ(2, section.Count());
EXPECT_EQ(2u, section.Count());
}
TEST(TagSectionTest,WriteNoOrderRewrite)
{
@@ -196,7 +196,7 @@ TEST(TagSectionTest,WriteNoOrderRewrite)
EXPECT_EQ(packageValue, section.FindS("Package"));
EXPECT_EQ(42, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteOrderRename)
{
@@ -220,7 +220,7 @@ TEST(TagSectionTest,WriteOrderRename)
EXPECT_EQ(typoValue, section.FindS("TypoB"));
EXPECT_EQ(1, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}
TEST(TagSectionTest,WriteOrderRemove)
{
@@ -243,7 +243,7 @@ TEST(TagSectionTest,WriteOrderRemove)
EXPECT_TRUE(section.Exists("Override-Backup"));
EXPECT_EQ(packageValue, section.FindS("Package"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(2, section.Count());
EXPECT_EQ(2u, section.Count());
}
TEST(TagSectionTest,WriteOrderRewrite)
{
@@ -266,5 +266,5 @@ TEST(TagSectionTest,WriteOrderRewrite)
EXPECT_EQ(packageValue, section.FindS("Package"));
EXPECT_EQ(42, section.FindI("Override"));
EXPECT_EQ(1, section.FindI("Override-Backup"));
EXPECT_EQ(4, section.Count());
EXPECT_EQ(4u, section.Count());
}

+ 13
- 13
test/libapt/uri_test.cc View File

@@ -11,7 +11,7 @@ TEST(URITest, BasicHTTP)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(90, U.Port);
EXPECT_EQ(90u, U.Port);
EXPECT_EQ("www.debian.org", U.Host);
EXPECT_EQ("/temp/test", U.Path);
EXPECT_EQ("http://www.debian.org:90/temp/test", (std::string)U);
@@ -23,7 +23,7 @@ TEST(URITest, BasicHTTP)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("jgg", U.User);
EXPECT_EQ("foo", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("ualberta.ca", U.Host);
EXPECT_EQ("/blah", U.Path);
EXPECT_EQ("http://jgg:foo@ualberta.ca/blah", (std::string)U);
@@ -35,7 +35,7 @@ TEST(URITest, BasicHTTP)
EXPECT_EQ("https", U.Access);
EXPECT_EQ("apt", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("example.org", U.Host);
EXPECT_EQ("/blah", U.Path);
EXPECT_EQ("https://apt@example.org/blah", (std::string)U);
@@ -49,7 +49,7 @@ TEST(URITest, SingeSlashFile)
EXPECT_EQ("file", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("", U.Host);
EXPECT_EQ("/usr/bin/foo", U.Path);
EXPECT_EQ("file:/usr/bin/foo", (std::string)U);
@@ -63,7 +63,7 @@ TEST(URITest, BasicCDROM)
EXPECT_EQ("cdrom", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("Moo Cow Rom", U.Host);
EXPECT_EQ("/debian", U.Path);
EXPECT_EQ("cdrom://Moo Cow Rom/debian", (std::string)U);
@@ -77,7 +77,7 @@ TEST(URITest, RelativeGzip)
EXPECT_EQ("gzip", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ(".", U.Host);
EXPECT_EQ("/bar/cow", U.Path);
EXPECT_EQ("gzip://./bar/cow", (std::string)U);
@@ -91,7 +91,7 @@ TEST(URITest, NoSlashFTP)
EXPECT_EQ("ftp", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("ftp.fr.debian.org", U.Host);
EXPECT_EQ("/debian/pool/main/x/xtel/xtel_3.2.1-15_i386.deb", U.Path);
EXPECT_EQ("ftp://ftp.fr.debian.org/debian/pool/main/x/xtel/xtel_3.2.1-15_i386.deb", (std::string)U);
@@ -105,7 +105,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("1080::8:800:200C:417A", U.Host);
EXPECT_EQ("/foo", U.Path);
EXPECT_EQ("http://[1080::8:800:200C:417A]/foo", (std::string)U);
@@ -117,7 +117,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(80, U.Port);
EXPECT_EQ(80u, U.Port);
EXPECT_EQ("::FFFF:129.144.52.38", U.Host);
EXPECT_EQ("/index.html", U.Path);
EXPECT_EQ("http://[::FFFF:129.144.52.38]:80/index.html", (std::string)U);
@@ -129,7 +129,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(80, U.Port);
EXPECT_EQ(80u, U.Port);
EXPECT_EQ("::FFFF:129.144.52.38:", U.Host);
EXPECT_EQ("/index.html", U.Path);
EXPECT_EQ("http://[::FFFF:129.144.52.38:]:80/index.html", (std::string)U);
@@ -141,7 +141,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("http", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("::FFFF:129.144.52.38:", U.Host);
EXPECT_EQ("/index.html", U.Path);
EXPECT_EQ("http://[::FFFF:129.144.52.38:]/index.html", (std::string)U);
@@ -154,7 +154,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("cdrom", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("The Debian 1.2 disk, 1/2 R1:6", U.Host);
EXPECT_EQ("/debian/", U.Path);
EXPECT_EQ("cdrom://[The Debian 1.2 disk, 1/2 R1:6]/debian/", (std::string)U);
@@ -166,7 +166,7 @@ TEST(URITest, RFC2732)
EXPECT_EQ("cdrom", U.Access);
EXPECT_EQ("", U.User);
EXPECT_EQ("", U.Password);
EXPECT_EQ(0, U.Port);
EXPECT_EQ(0u, U.Port);
EXPECT_EQ("Foo Bar Cow", U.Host);
EXPECT_EQ("/debian/", U.Path);
EXPECT_EQ("cdrom://Foo Bar Cow/debian/", (std::string)U);


Loading…
Cancel
Save