mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
[PR] Special function to encode query params (#801)
* Special function to encode query params * Fix #include <iomanip> * Added unescaped charsets to encode_query_param * Unit tests for encode_query_param
This commit is contained in:
parent
9cac2c9ceb
commit
78ea786abd
2 changed files with 41 additions and 2 deletions
12
test/test.cc
12
test/test.cc
|
@ -46,6 +46,18 @@ TEST(StartupTest, WSAStartup) {
|
|||
}
|
||||
#endif
|
||||
|
||||
TEST(EncodeQueryParamTest, ParseUnescapedChararactersTest){
|
||||
string unescapedCharacters = "-_.!~*'()";
|
||||
|
||||
EXPECT_EQ(detail::encode_query_param(unescapedCharacters), "-_.!~*'()");
|
||||
}
|
||||
|
||||
TEST(EncodeQueryParamTest, ParseReservedCharactersTest){
|
||||
string reservedCharacters = ";,/?:@&=+$";
|
||||
|
||||
EXPECT_EQ(detail::encode_query_param(reservedCharacters), "%3B%2C%2F%3F%3A%40%26%3D%2B%24");
|
||||
}
|
||||
|
||||
TEST(TrimTests, TrimStringTests) {
|
||||
EXPECT_EQ("abc", detail::trim_copy("abc"));
|
||||
EXPECT_EQ("abc", detail::trim_copy(" abc "));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue