summaryrefslogtreecommitdiff
path: root/test/libapt/strutil_test.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:57:24 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:57:24 +0100
commit56f5df0df7ece30fbf3b773d249e3e783a09724f (patch)
tree6d71c3b920209bc6636893f34f6e619418bd719b /test/libapt/strutil_test.cc
parent99813a2eaa7c0cce1d7d8c811827733ed66458de (diff)
parent355e1aceac1dd05c4c7daf3420b09bd860fd169d (diff)
Merge branch 'feature/altretries'
Generalizing the behaviour of retrying a download on the same server (if enabled via options) as well as retrying a download via a different alternative server from the acquire item responsible for deb files to the handling of items in general so that all are effected.
Diffstat (limited to 'test/libapt/strutil_test.cc')
-rw-r--r--test/libapt/strutil_test.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc
index 9c192a58b..f531c2bf9 100644
--- a/test/libapt/strutil_test.cc
+++ b/test/libapt/strutil_test.cc
@@ -319,3 +319,45 @@ TEST(StrUtilTest,RFC1123StrToTime)
EXPECT_FALSE(RFC1123StrToTime("Sunday, 06-Nov-94 08:49:37 -0100", t));
EXPECT_FALSE(RFC1123StrToTime("Sunday, 06-Nov-94 08:49:37 -0.1", t));
}
+TEST(StrUtilTest, LookupTag)
+{
+ EXPECT_EQ("", LookupTag("", "Field", ""));
+ EXPECT_EQ("", LookupTag("", "Field", nullptr));
+ EXPECT_EQ("default", LookupTag("", "Field", "default"));
+ EXPECT_EQ("default", LookupTag("Field1: yes", "Field", "default"));
+ EXPECT_EQ("default", LookupTag("Fiel: yes", "Field", "default"));
+ EXPECT_EQ("default", LookupTag("Fiel d: yes", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field: foo", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field: foo\n", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("\nField: foo\n", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field:foo", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field:foo\n", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("\nField:foo\n", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field:\tfoo\n", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field: foo \t", "Field", "default"));
+ EXPECT_EQ("foo", LookupTag("Field: foo \t\n", "Field", "default"));
+ EXPECT_EQ("Field : yes", LookupTag("Field: Field : yes \t\n", "Field", "default"));
+ EXPECT_EQ("Field : yes", LookupTag("Field:\n Field : yes \t\n", "Field", "default"));
+ EXPECT_EQ("Field : yes", LookupTag("Foo: bar\nField: Field : yes \t\n", "Field", "default"));
+ EXPECT_EQ("line1\nline2", LookupTag("Multi: line1\n line2", "Multi", "default"));
+ EXPECT_EQ("line1\nline2", LookupTag("Multi: line1\n line2\n", "Multi", "default"));
+ EXPECT_EQ("line1\nline2", LookupTag("Multi:\n line1\n line2\n", "Multi", "default"));
+ EXPECT_EQ("line1\n\nline2", LookupTag("Multi:\n line1\n .\n line2\n", "Multi", "default"));
+ EXPECT_EQ("line1\na\nline2", LookupTag("Multi:\n line1\n a\n line2\n", "Multi", "default"));
+ EXPECT_EQ("line1\nfoo\nline2", LookupTag("Multi:\n line1\n foo\n line2\n", "Multi", "default"));
+ EXPECT_EQ("line1\n line2", LookupTag("Multi: line1\n line2", "Multi", "default"));
+ EXPECT_EQ(" line1\n \t line2", LookupTag("Multi:\t \n line1\n \t line2\n", "Multi", "default"));
+ EXPECT_EQ(" line1\n\n\n \t line2", LookupTag("Multi:\t \n line1\n .\n . \n \t line2\n", "Multi", "default"));
+
+ std::string const msg =
+ "Field1: Value1\nField2:Value2\nField3:\t Value3\n"
+ "Multi-Field1: Line1\n Line2\nMulti-Field2:\n Line1\n Line2\n"
+ "Field4: Value4\nField5:Value5";
+ EXPECT_EQ("Value1", LookupTag(msg, "Field1", ""));
+ EXPECT_EQ("Value2", LookupTag(msg, "Field2", ""));
+ EXPECT_EQ("Value3", LookupTag(msg, "Field3", ""));
+ EXPECT_EQ("Line1\nLine2", LookupTag(msg, "Multi-Field1", ""));
+ EXPECT_EQ("Line1\nLine2", LookupTag(msg, "Multi-Field2", ""));
+ EXPECT_EQ("Value4", LookupTag(msg, "Field4", ""));
+ EXPECT_EQ("Value5", LookupTag(msg, "Field5", ""));
+}