Test get_header() with umlauts.

This commit is contained in:
tastytea 2020-11-08 01:24:59 +01:00
parent 63a14867c3
commit dbfee4c2bd
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 25 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include <catch.hpp>
#include <exception>
#include <locale>
#include <string>
namespace curl_wrapper
@ -22,17 +23,18 @@ Keep-Alive: timeout=20
Expires: Sat, 07 Nov 2020 22:56:13 GMT
Cache-Control: max-age=1800
X-Cache: HIT
X-UmläÜt: 🙂
)";
const string searchfor{"cache-control"};
bool exception = false;
string value;
WHEN("We search for " + searchfor)
std::locale::global(std::locale("de_DE.UTF-8"));
WHEN("We search for “cache-control”")
{
try
{
value = ret.get_header(searchfor);
value = ret.get_header("cache-control");
}
catch (const std::exception &e)
{
@ -46,6 +48,25 @@ X-Cache: HIT
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