52 lines
992 B
C++
52 lines
992 B
C++
#include "types.hpp"
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include <exception>
|
|
#include <string>
|
|
|
|
namespace curl_wrapper
|
|
{
|
|
|
|
using std::string;
|
|
|
|
SCENARIO("Extract header")
|
|
{
|
|
answer ret;
|
|
ret.headers = R"(HTTP/1.1 200 OK
|
|
Server: nginx/1.18.0
|
|
Date: Sat, 07 Nov 2020 22:26:13 GMT
|
|
Content-Type: application/rss+xml; charset=utf-8
|
|
Connection: keep-alive
|
|
Keep-Alive: timeout=20
|
|
Expires: Sat, 07 Nov 2020 22:56:13 GMT
|
|
Cache-Control: max-age=1800
|
|
X-Cache: HIT
|
|
)";
|
|
const string searchfor{"cache-control"};
|
|
|
|
bool exception = false;
|
|
string value;
|
|
|
|
WHEN("We search for " + searchfor)
|
|
{
|
|
try
|
|
{
|
|
value = ret.get_header(searchfor);
|
|
}
|
|
catch (const std::exception &e)
|
|
{
|
|
exception = true;
|
|
}
|
|
|
|
THEN("No exception is thrown")
|
|
AND_THEN("The value is successfully extracted")
|
|
{
|
|
REQUIRE_FALSE(exception);
|
|
REQUIRE(value == "max-age=1800");
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace curl_wrapper
|