blob: d091248f8922c684762960f5e0d3c5cff7a0ad87 [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
George Liu647b3cd2021-07-05 12:43:56 +080010TEST(HttpUtility, requestPrefersHtml)
11{
Nan Zhouad3edd42022-06-21 17:46:44 +000012 EXPECT_FALSE(requestPrefersHtml("*/*, application/octet-stream"));
13 EXPECT_TRUE(isOctetAccepted("*/*, application/octet-stream"));
George Liu647b3cd2021-07-05 12:43:56 +080014
Nan Zhouad3edd42022-06-21 17:46:44 +000015 EXPECT_TRUE(requestPrefersHtml("text/html, application/json"));
16 EXPECT_FALSE(isOctetAccepted("text/html, application/json"));
George Liu647b3cd2021-07-05 12:43:56 +080017
Nan Zhouad3edd42022-06-21 17:46:44 +000018 EXPECT_FALSE(requestPrefersHtml("application/json"));
19 EXPECT_FALSE(isOctetAccepted("application/json"));
George Liu647b3cd2021-07-05 12:43:56 +080020}
Nan Zhouad3edd42022-06-21 17:46:44 +000021
22} // namespace
23} // namespace http_helpers