proxygen
HTTPCommonHeadersTests.cpp File Reference

Go to the source code of this file.

Classes

class  HTTPCommonHeadersTests
 

Functions

 TEST_F (HTTPCommonHeadersTests, TestHashing)
 
 TEST_F (HTTPCommonHeadersTests, TestTwoTablesInitialized)
 
 TEST_F (HTTPCommonHeadersTests, TestIsCommonHeaderNameFromTable)
 
 TEST_F (HTTPCommonHeadersTests, TestGetHeaderCodeFromTableCommonHeaderName)
 

Function Documentation

TEST_F ( HTTPCommonHeadersTests  ,
TestHashing   
)

Definition at line 18 of file HTTPCommonHeadersTests.cpp.

References EXPECT_EQ, EXPECT_NE, proxygen::HTTPCommonHeaders::hash(), proxygen::HTTP_HEADER_OTHER, and string.

18  {
19  std::string common1("Content-Length");
20  std::string common2("content-length");
21  std::string uncommon("Uncommon");
22 
23  HTTPHeaderCode commonCode1 = HTTPCommonHeaders::hash(common1);
24  HTTPHeaderCode commonCode2 = HTTPCommonHeaders::hash(common2);
25  HTTPHeaderCode uncommonCode = HTTPCommonHeaders::hash(uncommon);
26 
29 
30  EXPECT_EQ(commonCode1, commonCode2);
31 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const char * string
Definition: Conv.cpp:212
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
TEST_F ( HTTPCommonHeadersTests  ,
TestTwoTablesInitialized   
)

Definition at line 33 of file HTTPCommonHeadersTests.cpp.

References EXPECT_EQ, proxygen::HTTPCommonHeaders::getPointerToHeaderName(), proxygen::HTTPCommonHeaders::hash(), string, and proxygen::TABLE_LOWERCASE.

33  {
34  std::string common("Content-Length");
35  HTTPHeaderCode code = HTTPCommonHeaders::hash(common);
36 
37  EXPECT_EQ(*HTTPCommonHeaders::getPointerToHeaderName(code), "Content-Length");
38  EXPECT_EQ(
39  *HTTPCommonHeaders::getPointerToHeaderName(
40  code, HTTPCommonHeaderTableType::TABLE_LOWERCASE), "content-length");
41 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
Definition: common.py:1
const char * string
Definition: Conv.cpp:212
TEST_F ( HTTPCommonHeadersTests  ,
TestIsCommonHeaderNameFromTable   
)

Definition at line 43 of file HTTPCommonHeadersTests.cpp.

References EXPECT_FALSE, EXPECT_TRUE, proxygen::HTTPCommonHeaders::getPointerToHeaderName(), proxygen::HTTP_HEADER_NONE, proxygen::HTTP_HEADER_OTHER, proxygen::HTTPHeaderCodeCommonOffset, proxygen::HTTPCommonHeaders::isHeaderNameFromTable(), proxygen::HTTPCommonHeaders::num_header_codes, string, and proxygen::TABLE_CAMELCASE.

43  {
44  // The first two hardcoded headers are not considered actual common headers
46  HTTPCommonHeaders::isHeaderNameFromTable(
47  HTTPCommonHeaders::getPointerToHeaderName(HTTP_HEADER_NONE),
50  HTTPCommonHeaders::isHeaderNameFromTable(
51  HTTPCommonHeaders::getPointerToHeaderName(HTTP_HEADER_OTHER),
53 
54  // Verify that the first actual common header in the address table checks out
55  // Assuming there is at least one common header in the table (first two
56  // entries are HTTP_HEADER_NONE and HTTP_HEADER_OTHER)
57  if (HTTPCommonHeaders::num_header_codes > HTTPHeaderCodeCommonOffset) {
59  HTTPCommonHeaders::isHeaderNameFromTable(
60  HTTPCommonHeaders::getPointerToHeaderName(
61  static_cast<HTTPHeaderCode>(HTTPHeaderCodeCommonOffset + 1)),
63 
64  // Verify that the last header in the common address table checks out
66  HTTPCommonHeaders::isHeaderNameFromTable(
67  HTTPCommonHeaders::getPointerToHeaderName(
68  static_cast<HTTPHeaderCode>(
69  HTTPCommonHeaders::num_header_codes - 1)), TABLE_CAMELCASE));
70  }
71 
72  // Verify that a random header is not identified as being part of the common
73  // address table
74  std::string externalHeader = "externalHeader";
75  EXPECT_FALSE(HTTPCommonHeaders::isHeaderNameFromTable(
76  &externalHeader, TABLE_CAMELCASE));
77 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
const uint8_t HTTPHeaderCodeCommonOffset
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST_F ( HTTPCommonHeadersTests  ,
TestGetHeaderCodeFromTableCommonHeaderName   
)

Definition at line 79 of file HTTPCommonHeadersTests.cpp.

References EXPECT_TRUE, proxygen::HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName(), proxygen::HTTPCommonHeaders::getPointerToHeaderName(), proxygen::HTTP_HEADER_OTHER, proxygen::HTTPHeaderCodeCommonOffset, proxygen::HTTPCommonHeaders::num_header_codes, string, proxygen::TABLE_CAMELCASE, and uint64_t.

79  {
81  j < HTTPCommonHeaders::num_header_codes; ++j) {
82  HTTPHeaderCode code = static_cast<HTTPHeaderCode>(j);
84  code ==
85  HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName(
86  HTTPCommonHeaders::getPointerToHeaderName(code), TABLE_CAMELCASE));
87  }
88  std::string externalHeader = "externalHeader";
90  HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName(
91  &externalHeader, TABLE_CAMELCASE));
92 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
const uint8_t HTTPHeaderCodeCommonOffset