]> git.saurik.com Git - apt.git/blobdiff - test/libapt/strutil_test.cc
Don't download "optional" files not in Release :/.
[apt.git] / test / libapt / strutil_test.cc
index 23dc08727a3edaa1d991e50593df9aa2bc4bca4d..d7700bd5405fa07934d01bbc161e739fe66a4f43 100644 (file)
@@ -168,7 +168,7 @@ TEST(StrUtilTest,Base64Encode)
    EXPECT_EQ("Lg==", Base64Encode("."));
    EXPECT_EQ("", Base64Encode(""));
 }
-void ReadMessagesTestWithNewLine(char const * const nl, char const * const ab)
+static void ReadMessagesTestWithNewLine(char const * const nl, char const * const ab)
 {
    SCOPED_TRACE(SubstVar(SubstVar(nl, "\n", "n"), "\r", "r") + " # " + ab);
    FileFd fd;
@@ -235,3 +235,87 @@ TEST(StrUtilTest,ReadMessages)
    ReadMessagesTestWithNewLine("\n\n", "ab");
    ReadMessagesTestWithNewLine("\r\n\r\n", "ab");
 }
+TEST(StrUtilTest,QuoteString)
+{
+   EXPECT_EQ("", QuoteString("", ""));
+   EXPECT_EQ("K%c3%b6ln", QuoteString("Köln", ""));
+   EXPECT_EQ("Köln", DeQuoteString(QuoteString("Köln", "")));
+   EXPECT_EQ("Köln", DeQuoteString(DeQuoteString(QuoteString(QuoteString("Köln", ""), ""))));
+   EXPECT_EQ("~-_$#|u%c3%a4%c3%b6%c5%a6%e2%84%a2%e2%85%9e%c2%b1%c3%86%e1%ba%9e%c2%aa%c3%9f", QuoteString("~-_$#|uäöŦ™⅞±Æẞªß", ""));
+   EXPECT_EQ("~-_$#|uäöŦ™⅞±Æẞªß", DeQuoteString(QuoteString("~-_$#|uäöŦ™⅞±Æẞªß", "")));
+   EXPECT_EQ("%45ltvill%65%2d%45rbach", QuoteString("Eltville-Erbach", "E-Ae"));
+   EXPECT_EQ("Eltville-Erbach", DeQuoteString(QuoteString("Eltville-Erbach", "")));
+}
+
+TEST(StrUtilTest,RFC1123StrToTime)
+{
+   {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37 GMT", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 6 Nov 1994 08:49:37 UTC", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun,  6 Nov 1994 08:49:37 UTC", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 06 Nov 1994  8:49:37 UTC", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37 UTC", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37 -0000", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37 +0000", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sunday, 06-Nov-94 08:49:37 GMT", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sunday,  6-Nov-94 08:49:37 GMT", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sunday, 06-Nov-94 8:49:37 GMT", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun Nov  6 08:49:37 1994", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun Nov 06 08:49:37 1994", t));
+      EXPECT_EQ(784111777, t);
+   } {
+      time_t t;
+      EXPECT_TRUE(RFC1123StrToTime("Sun Nov  6  8:49:37 1994", t));
+      EXPECT_EQ(784111777, t);
+   }
+   time_t t;
+   EXPECT_FALSE(RFC1123StrToTime("So, 06 Nov 1994 08:49:37 UTC", t));
+   EXPECT_FALSE(RFC1123StrToTime(", 06 Nov 1994 08:49:37 UTC", t));
+   EXPECT_FALSE(RFC1123StrToTime("Son, 06 Nov 1994 08:49:37 UTC", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sun: 06 Nov 1994 08:49:37 UTC", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sun, 06 Nov 1994 08:49:37 GMT+1", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sun, 06 Nov 1994 GMT", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sunday, 06 Nov 1994 GMT", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sonntag, 06 Nov 1994 08:49:37 GMT", t));
+   EXPECT_FALSE(RFC1123StrToTime("domingo Nov 6 08:49:37 1994", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sunday: 06-Nov-94 08:49:37 GMT", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sunday, 06-Nov-94 08:49:37 GMT+1", t));
+   EXPECT_FALSE(RFC1123StrToTime("Sunday, 06-Nov-94 08:49:37 EDT", t));
+   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));
+}