summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-09-10 08:13:18 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-10 08:13:18 +0200
commit2fa9c1eee57775309f79b63baa5d165b7b443969 (patch)
tree21907ec26aba35dff2185aa463f38e9ec0686c78 /test/libapt
parent9bac4dce7c1454b4919800a47ffc5860fd3c7e1b (diff)
parent7d8a4da74eb7f794e4da1216b39d7e2a1259d18f (diff)
Merge branch 'debian/sid' into ubuntu/master
Conflicts: configure.ac debian/changelog doc/apt-verbatim.ent doc/po/apt-doc.pot doc/po/de.po doc/po/es.po doc/po/fr.po doc/po/it.po doc/po/ja.po doc/po/pl.po doc/po/pt.po doc/po/pt_BR.po po/apt-all.pot po/ar.po po/ast.po po/bg.po po/bs.po po/ca.po po/cs.po po/cy.po po/da.po po/de.po po/dz.po po/el.po po/es.po po/eu.po po/fi.po po/fr.po po/gl.po po/hu.po po/it.po po/ja.po po/km.po po/ko.po po/ku.po po/lt.po po/mr.po po/nb.po po/ne.po po/nl.po po/nn.po po/pl.po po/pt.po po/pt_BR.po po/ro.po po/ru.po po/sk.po po/sl.po po/sv.po po/th.po po/tl.po po/tr.po po/uk.po po/vi.po po/zh_CN.po po/zh_TW.po
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/commandline_test.cc29
-rw-r--r--test/libapt/parsedepends_test.cc4
-rw-r--r--test/libapt/strutil_test.cc50
3 files changed, 81 insertions, 2 deletions
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
index 26e80bfde..e403a28c8 100644
--- a/test/libapt/commandline_test.cc
+++ b/test/libapt/commandline_test.cc
@@ -56,3 +56,32 @@ TEST(CommandLineTest,Parsing)
EXPECT_TRUE(c.FindB("Test::Worked", false));
EXPECT_FALSE(c.FindB("Test::Zero", false));
}
+
+TEST(CommandLineTest, BoolParsing)
+{
+ CommandLine::Args Args[] = {
+ { 't', 0, "Test::Worked", 0 },
+ {0,0,0,0}
+ };
+ ::Configuration c;
+ CommandLine CmdL(Args, &c);
+
+ // the commandline parser used to use strtol() on the argument
+ // to check if the argument is a boolean expression - that
+ // stopped after the "0". this test ensures that we always check
+ // that the entire string was consumed by strtol
+ {
+ char const * argv[] = { "show", "-t", "0ad" };
+ bool res = CmdL.Parse(sizeof(argv)/sizeof(char*), argv);
+ EXPECT_TRUE(res);
+ ASSERT_EQ(std::string(CmdL.FileList[0]), "0ad");
+ }
+
+ {
+ char const * argv[] = { "show", "-t", "0", "ad" };
+ bool res = CmdL.Parse(sizeof(argv)/sizeof(char*), argv);
+ EXPECT_TRUE(res);
+ ASSERT_EQ(std::string(CmdL.FileList[0]), "ad");
+ }
+
+}
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
index 1e0afb66c..52eac8232 100644
--- a/test/libapt/parsedepends_test.cc
+++ b/test/libapt/parsedepends_test.cc
@@ -23,7 +23,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
"libdb-dev:any, "
"gettext:native (<= 0.12), "
"libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), "
- "debiandoc-sgml, "
+ "docbook-xml, "
"apt (>= 0.7.25), "
"not-for-me [ !amd64 ], "
"only-for-me [ amd64 ], "
@@ -82,7 +82,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
EXPECT_EQ(Null | pkgCache::Dep::Greater, Op);
Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
- EXPECT_EQ("debiandoc-sgml", Package);
+ EXPECT_EQ("docbook-xml", Package);
EXPECT_EQ("", Version);
EXPECT_EQ(Null | pkgCache::Dep::NoOp, Op);
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc
index bc004fd66..194c9c074 100644
--- a/test/libapt/strutil_test.cc
+++ b/test/libapt/strutil_test.cc
@@ -19,6 +19,21 @@ TEST(StrUtilTest,DeEscapeString)
EXPECT_EQ("foo\\ x", DeEscapeString("foo\\\\ x"));
EXPECT_EQ("\\foo\\", DeEscapeString("\\\\foo\\\\"));
}
+TEST(StrUtilTest,StringStrip)
+{
+ EXPECT_EQ("", APT::String::Strip(""));
+ EXPECT_EQ("foobar", APT::String::Strip("foobar"));
+ EXPECT_EQ("foo bar", APT::String::Strip("foo bar"));
+
+ EXPECT_EQ("", APT::String::Strip(" "));
+ EXPECT_EQ("", APT::String::Strip(" \r\n \t "));
+
+ EXPECT_EQ("foo bar", APT::String::Strip("foo bar "));
+ EXPECT_EQ("foo bar", APT::String::Strip("foo bar \r\n \t "));
+ EXPECT_EQ("foo bar", APT::String::Strip("\r\n \t foo bar"));
+ EXPECT_EQ("bar foo", APT::String::Strip("\r\n \t bar foo \r\n \t "));
+ EXPECT_EQ("bar \t\r\n foo", APT::String::Strip("\r\n \t bar \t\r\n foo \r\n \t "));
+}
TEST(StrUtilTest,StringSplitBasic)
{
std::vector<std::string> result = StringSplit("", "");
@@ -70,3 +85,38 @@ TEST(StrUtilTest,EndsWith)
EXPECT_FALSE(Endswith("abcd", "x"));
EXPECT_FALSE(Endswith("abcd", "abcndefg"));
}
+TEST(StrUtilTest,SubstVar)
+{
+ EXPECT_EQ("", SubstVar("", "fails", "passes"));
+ EXPECT_EQ("test ", SubstVar("test fails", "fails", ""));
+ EXPECT_EQ("test passes", SubstVar("test passes", "", "fails"));
+
+ EXPECT_EQ("test passes", SubstVar("test passes", "fails", "passes"));
+ EXPECT_EQ("test passes", SubstVar("test fails", "fails", "passes"));
+
+ EXPECT_EQ("starts with", SubstVar("beginnt with", "beginnt", "starts"));
+ EXPECT_EQ("beginnt with", SubstVar("starts with", "starts", "beginnt"));
+ EXPECT_EQ("is in middle", SubstVar("is in der middle", "in der", "in"));
+ EXPECT_EQ("is in der middle", SubstVar("is in middle", "in", "in der"));
+ EXPECT_EQ("does end", SubstVar("does enden", "enden", "end"));
+ EXPECT_EQ("does enden", SubstVar("does end", "end", "enden"));
+
+ EXPECT_EQ("abc", SubstVar("abc", "d", "a"));
+ EXPECT_EQ("abc", SubstVar("abd", "d", "c"));
+ EXPECT_EQ("abc", SubstVar("adc", "d", "b"));
+ EXPECT_EQ("abc", SubstVar("dbc", "d", "a"));
+
+ EXPECT_EQ("b", SubstVar("b", "aa", "a"));
+ EXPECT_EQ("bb", SubstVar("bb", "aa", "a"));
+ EXPECT_EQ("bbb", SubstVar("bbb", "aa", "a"));
+
+ EXPECT_EQ("aa", SubstVar("aaaa", "aa", "a"));
+ EXPECT_EQ("aaaa", SubstVar("aa", "a", "aa"));
+ EXPECT_EQ("aaaa", SubstVar("aaaa", "a", "a"));
+ EXPECT_EQ("a a a a ", SubstVar("aaaa", "a", "a "));
+
+ EXPECT_EQ(" bb bb bb bb ", SubstVar(" a a a a ", "a", "bb"));
+ EXPECT_EQ(" bb bb bb bb ", SubstVar(" aaa aaa aaa aaa ", "aaa", "bb"));
+ EXPECT_EQ(" bb a bb a bb a bb ", SubstVar(" aaa a aaa a aaa a aaa ", "aaa", "bb"));
+
+}