summaryrefslogtreecommitdiffstats
path: root/test/libapt/parsedepends_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/libapt/parsedepends_test.cc')
-rw-r--r--test/libapt/parsedepends_test.cc52
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"));
+ }
+}