Test get_header() with umlauts.
This commit is contained in:
parent
63a14867c3
commit
dbfee4c2bd
|
@ -3,6 +3,7 @@
|
||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace curl_wrapper
|
namespace curl_wrapper
|
||||||
|
@ -22,17 +23,18 @@ Keep-Alive: timeout=20
|
||||||
Expires: Sat, 07 Nov 2020 22:56:13 GMT
|
Expires: Sat, 07 Nov 2020 22:56:13 GMT
|
||||||
Cache-Control: max-age=1800
|
Cache-Control: max-age=1800
|
||||||
X-Cache: HIT
|
X-Cache: HIT
|
||||||
|
X-UmläÜt: 🙂
|
||||||
)";
|
)";
|
||||||
const string searchfor{"cache-control"};
|
|
||||||
|
|
||||||
bool exception = false;
|
bool exception = false;
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
WHEN("We search for " + searchfor)
|
std::locale::global(std::locale("de_DE.UTF-8"));
|
||||||
|
|
||||||
|
WHEN("We search for “cache-control”")
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
value = ret.get_header(searchfor);
|
value = ret.get_header("cache-control");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -46,6 +48,25 @@ X-Cache: HIT
|
||||||
REQUIRE(value == "max-age=1800");
|
REQUIRE(value == "max-age=1800");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WHEN("We search for “X-UMLÄÜT”")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
value = ret.get_header("X-UMLÄÜT");
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
THEN("No exception is thrown")
|
||||||
|
AND_THEN("The value is successfully extracted")
|
||||||
|
{
|
||||||
|
REQUIRE_FALSE(exception);
|
||||||
|
REQUIRE(value == "🙂");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace curl_wrapper
|
} // namespace curl_wrapper
|
||||||
|
|
Loading…
Reference in New Issue