blob: e412e1753621181aa21fe8d0be9ccf4b0e17c81b [file] [log] [blame]
Nan Zhou93b443d2022-06-21 17:46:51 +00001#include "http_utility.hpp"
George Liu647b3cd2021-07-05 12:43:56 +08002
Nan Zhoud5c80ad2022-07-11 01:16:31 +00003#include <gtest/gtest.h> // IWYU pragma: keep
4
5// IWYU pragma: no_include <gtest/gtest-message.h>
6// IWYU pragma: no_include <gtest/gtest-test-part.h>
7// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
George Liu647b3cd2021-07-05 12:43:56 +08008
Nan Zhouad3edd42022-06-21 17:46:44 +00009namespace http_helpers
10{
11namespace
12{
13
Nan Zhoua02b5862022-06-21 17:46:56 +000014TEST(RequestPrefersHtml, ContainsHtmlReturnsTrue)
15{
16 EXPECT_TRUE(requestPrefersHtml("text/html, application/json"));
17}
18
19TEST(RequestPrefersHtml, NoHtmlReturnsFalse)
George Liu647b3cd2021-07-05 12:43:56 +080020{
Nan Zhouad3edd42022-06-21 17:46:44 +000021 EXPECT_FALSE(requestPrefersHtml("*/*, application/octet-stream"));
Nan Zhouad3edd42022-06-21 17:46:44 +000022 EXPECT_FALSE(requestPrefersHtml("application/json"));
Nan Zhoua02b5862022-06-21 17:46:56 +000023}
24
25TEST(IsOctetAccepted, ContainsOctetReturnsTrue)
26{
27 EXPECT_TRUE(isOctetAccepted("*/*, application/octet-stream"));
28}
29
30TEST(IsOctetAccepted, NoOctetReturnsFalse)
31{
32 EXPECT_FALSE(isOctetAccepted("text/html, application/json"));
Nan Zhouad3edd42022-06-21 17:46:44 +000033 EXPECT_FALSE(isOctetAccepted("application/json"));
George Liu647b3cd2021-07-05 12:43:56 +080034}
Nan Zhouad3edd42022-06-21 17:46:44 +000035
36} // namespace
37} // namespace http_helpers