From 822fb3748af8b27837c4e2758ba820f7c5dfb038 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 18 Jan 2023 17:24:46 +0400 Subject: [PATCH] Added a unit-test for urlDecode() --- test/stringTools.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/stringTools.cpp b/test/stringTools.cpp index 462517668..890688756 100644 --- a/test/stringTools.cpp +++ b/test/stringTools.cpp @@ -147,4 +147,26 @@ TEST(stringTools, urlEncode) EXPECT_EQ(urlEncode(someNonASCIIChars), urlEncode(someNonASCIIChars, true)); } +TEST(stringTools, urlDecode) +{ + using namespace URLEncoding; + + const std::string allTestChars = std::string(letters) + + digits + + nonEncodableSymbols + + uriDelimSymbols + + otherSymbols + + whitespace + + someNonASCIIChars; + + for ( const char c : allTestChars ) { + const std::string str(1, c); + EXPECT_EQ(urlDecode(urlEncode(str)), str); + EXPECT_EQ(urlDecode(urlEncode(str, true), true), str); + } + + EXPECT_EQ(urlDecode(urlEncode(allTestChars)), allTestChars); + EXPECT_EQ(urlDecode(urlEncode(allTestChars, true), true), allTestChars); +} + };