Nan Zhou | 93b443d | 2022-06-21 17:46:51 +0000 | [diff] [blame] | 1 | #include "http_utility.hpp" |
George Liu | 647b3cd | 2021-07-05 12:43:56 +0800 | [diff] [blame] | 2 | |
Nan Zhou | 93b443d | 2022-06-21 17:46:51 +0000 | [diff] [blame] | 3 | #include <gtest/gtest.h> |
George Liu | 647b3cd | 2021-07-05 12:43:56 +0800 | [diff] [blame] | 4 | |
Nan Zhou | ad3edd4 | 2022-06-21 17:46:44 +0000 | [diff] [blame] | 5 | namespace http_helpers |
| 6 | { |
| 7 | namespace |
| 8 | { |
| 9 | |
Nan Zhou | a02b586 | 2022-06-21 17:46:56 +0000 | [diff] [blame^] | 10 | TEST(RequestPrefersHtml, ContainsHtmlReturnsTrue) |
| 11 | { |
| 12 | EXPECT_TRUE(requestPrefersHtml("text/html, application/json")); |
| 13 | } |
| 14 | |
| 15 | TEST(RequestPrefersHtml, NoHtmlReturnsFalse) |
George Liu | 647b3cd | 2021-07-05 12:43:56 +0800 | [diff] [blame] | 16 | { |
Nan Zhou | ad3edd4 | 2022-06-21 17:46:44 +0000 | [diff] [blame] | 17 | EXPECT_FALSE(requestPrefersHtml("*/*, application/octet-stream")); |
Nan Zhou | ad3edd4 | 2022-06-21 17:46:44 +0000 | [diff] [blame] | 18 | EXPECT_FALSE(requestPrefersHtml("application/json")); |
Nan Zhou | a02b586 | 2022-06-21 17:46:56 +0000 | [diff] [blame^] | 19 | } |
| 20 | |
| 21 | TEST(IsOctetAccepted, ContainsOctetReturnsTrue) |
| 22 | { |
| 23 | EXPECT_TRUE(isOctetAccepted("*/*, application/octet-stream")); |
| 24 | } |
| 25 | |
| 26 | TEST(IsOctetAccepted, NoOctetReturnsFalse) |
| 27 | { |
| 28 | EXPECT_FALSE(isOctetAccepted("text/html, application/json")); |
Nan Zhou | ad3edd4 | 2022-06-21 17:46:44 +0000 | [diff] [blame] | 29 | EXPECT_FALSE(isOctetAccepted("application/json")); |
George Liu | 647b3cd | 2021-07-05 12:43:56 +0800 | [diff] [blame] | 30 | } |
Nan Zhou | ad3edd4 | 2022-06-21 17:46:44 +0000 | [diff] [blame] | 31 | |
| 32 | } // namespace |
| 33 | } // namespace http_helpers |