diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 02:48:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 02:48:10 +0000 |
commit | 7f9ceaec776a597e9ff8451038d57dd75e1e6d18 (patch) | |
tree | 284aa831d7c1c097a28b9048e594e071efa8e65c /test/libapt/parsedepends_test.cc | |
parent | Releasing progress-linux version 2.9.3-0.0~progress7.99u1. (diff) | |
download | apt-7f9ceaec776a597e9ff8451038d57dd75e1e6d18.tar.xz apt-7f9ceaec776a597e9ff8451038d57dd75e1e6d18.zip |
Merging upstream version 2.9.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/libapt/parsedepends_test.cc')
-rw-r--r-- | test/libapt/parsedepends_test.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index 9771c5d..296750b 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -311,3 +311,55 @@ TEST(ParseDependsTest, SpaceHate) EXPECT_EQ("1", Version); EXPECT_EQ(pkgCache::Dep::Equals, Op); } + +static void ArchLimitSpaceTesting(char const * const Depends) +{ + SCOPED_TRACE(Depends); + _config->Set("APT::Architecture", "amd64"); + 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, true, false, true, "amd64"); + EXPECT_NE(nullptr, Start); + EXPECT_EQ("foobar", Package); + EXPECT_EQ("", Version); + EXPECT_EQ(pkgCache::Dep::NoOp, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, true, false, true, "amd64"); + EXPECT_NE(nullptr, Start); + EXPECT_EQ("", Package); + EXPECT_EQ("", Version); + EXPECT_EQ(pkgCache::Dep::NoOp, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, true, false, true, "amd64"); + EXPECT_EQ(End, Start); + EXPECT_EQ("baz", Package); + EXPECT_EQ("", Version); + EXPECT_EQ(pkgCache::Dep::NoOp, Op); +} +TEST(ParseDependsTest, ArchLimitSpaceNormal) +{ + ArchLimitSpaceTesting("foobar [i386 armhf armel amd64], blah [!arm64 !x32 !amd64], baz"); +} +TEST(ParseDependsTest, ArchLimitSpaceLove) +{ + ArchLimitSpaceTesting("foobar [ i386 armhf armel amd64 ] , blah [ !arm64 !x32 !amd64 ] , baz"); +} +TEST(ParseDependsTest, ArchLimitSpaceNoLove) +{ + ArchLimitSpaceTesting("foobar[i386 armhf armel amd64],blah[!arm64 !x32 !amd64],baz"); +} +TEST(ParseDependsTest, ArchLimitBadSyntax) +{ + std::string Package; + std::string Version; + unsigned int Op = 29; + for (auto const * const Depends : { "foobar [! amd64]", "foobar []", "foobar [ ]" }) + { + SCOPED_TRACE(Depends); + EXPECT_EQ(nullptr, debListParser::ParseDepends(Depends, Depends + strlen(Depends), Package, Version, Op, true, false, true, "amd64")); + } +} |