mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Remove code duplication in converting params to query
This commit is contained in:
parent
f2bb9c45d6
commit
ccc9a9b3f4
2 changed files with 31 additions and 14 deletions
15
test/test.cc
15
test/test.cc
|
@ -77,6 +77,21 @@ TEST(ParseQueryTest, ParseQueryString) {
|
|||
EXPECT_EQ("val3", dic.find("key3")->second);
|
||||
}
|
||||
|
||||
TEST(ParamsToQueryTest, ConvertParamsToQuery) {
|
||||
Params dic;
|
||||
|
||||
EXPECT_EQ(detail::params_to_query_str(dic), "");
|
||||
|
||||
dic.emplace("key1", "val1");
|
||||
|
||||
EXPECT_EQ(detail::params_to_query_str(dic), "key1=val1");
|
||||
|
||||
dic.emplace("key2", "val2");
|
||||
dic.emplace("key3", "val3");
|
||||
|
||||
EXPECT_EQ(detail::params_to_query_str(dic), "key1=val1&key2=val2&key3=val3");
|
||||
}
|
||||
|
||||
TEST(GetHeaderValueTest, DefaultValue) {
|
||||
Headers headers = {{"Dummy", "Dummy"}};
|
||||
auto val = detail::get_header_value(headers, "Content-Type", 0, "text/plain");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue