Add more tests for decoding and encoding URL functions

This commit is contained in:
Luis Diaz Mas
2018-08-26 14:15:46 +02:00
committed by Luis Díaz Más
parent eefee8125b
commit 5d76036af5
2 changed files with 26 additions and 0 deletions
+23
View File
@@ -83,3 +83,26 @@ TEST(urlencode, encodesGivenUrl)
const std::string url = urlencode("http://www.geekhideout.com/urlcode.shtml");
ASSERT_STREQ("http%3a%2f%2fwww.geekhideout.com%2furlcode.shtml", url.c_str());
}
TEST(urlencode, encodesGivenUrlWithSpace)
{
const std::string url = urlencode("http://www.geekhideout.com/url code.shtml");
ASSERT_STREQ("http%3a%2f%2fwww.geekhideout.com%2furl+code.shtml", url.c_str());
}
TEST(urldecode, decodesGivenUrl)
{
const std::string expectedDecodedUrl ("http://www.geekhideout.com/urlcode.shtml");
const std::string url ("http%3a%2f%2fwww.geekhideout.com%2furlcode.shtml");
char * url3 = urldecode(url.c_str());
ASSERT_STREQ(expectedDecodedUrl.c_str(), url3);
free(url3);
}
TEST(urldecode, decodesGivenUrlInPlace)
{
const std::string expectedDecodedUrl ("http://www.geekhideout.com/urlcode.shtml");
std::string url ("http%3a%2f%2fwww.geekhideout.com%2furlcode.shtml");
urldecode(url);
ASSERT_STREQ(expectedDecodedUrl.c_str(), url.c_str());
}