summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-11-04 23:38:40 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-05 12:21:33 +0100
commit4453cfdcf42f7fe6859bb0fc6b310a2a391bee77 (patch)
treec448b9ec5b7dbbd1b6afd495f0831dd95e1c8180 /test
parent258b9e512c4001e806c5c0966acecd3d742ec6e9 (diff)
encode UTF-8 characters correctly in QuoteString
Limit the field length to a char to avoid bogus FF for utf-8 characters with the default length. Closes: 799123
Diffstat (limited to 'test')
-rw-r--r--test/libapt/strutil_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc
index 23dc08727..8947aea59 100644
--- a/test/libapt/strutil_test.cc
+++ b/test/libapt/strutil_test.cc
@@ -235,3 +235,14 @@ 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", "")));
+}