blob: c92bf1e4e54cdd02a9183279937197748740a09f [file] [log] [blame]
Nan Zhou93b443d2022-06-21 17:46:51 +00001#include "http_utility.hpp"
George Liu647b3cd2021-07-05 12:43:56 +08002
Nan Zhou93b443d2022-06-21 17:46:51 +00003#include <gtest/gtest.h>
George Liu647b3cd2021-07-05 12:43:56 +08004
Nan Zhouad3edd42022-06-21 17:46:44 +00005namespace http_helpers
6{
7namespace
8{
9
Nan Zhoua02b5862022-06-21 17:46:56 +000010TEST(RequestPrefersHtml, ContainsHtmlReturnsTrue)
11{
12 EXPECT_TRUE(requestPrefersHtml("text/html, application/json"));
13}
14
15TEST(RequestPrefersHtml, NoHtmlReturnsFalse)
George Liu647b3cd2021-07-05 12:43:56 +080016{
Nan Zhouad3edd42022-06-21 17:46:44 +000017 EXPECT_FALSE(requestPrefersHtml("*/*, application/octet-stream"));
Nan Zhouad3edd42022-06-21 17:46:44 +000018 EXPECT_FALSE(requestPrefersHtml("application/json"));
Nan Zhoua02b5862022-06-21 17:46:56 +000019}
20
21TEST(IsOctetAccepted, ContainsOctetReturnsTrue)
22{
23 EXPECT_TRUE(isOctetAccepted("*/*, application/octet-stream"));
24}
25
26TEST(IsOctetAccepted, NoOctetReturnsFalse)
27{
28 EXPECT_FALSE(isOctetAccepted("text/html, application/json"));
Nan Zhouad3edd42022-06-21 17:46:44 +000029 EXPECT_FALSE(isOctetAccepted("application/json"));
George Liu647b3cd2021-07-05 12:43:56 +080030}
Nan Zhouad3edd42022-06-21 17:46:44 +000031
32} // namespace
33} // namespace http_helpers