From dbfee4c2bd4daab4aca8bff573b3fd9335950df2 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 8 Nov 2020 01:24:59 +0100 Subject: [PATCH] Test get_header() with umlauts. --- tests/test_headers.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/test_headers.cpp b/tests/test_headers.cpp index 456ec78..73a6822 100644 --- a/tests/test_headers.cpp +++ b/tests/test_headers.cpp @@ -3,6 +3,7 @@ #include #include +#include #include 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