proxygen
RFCExamplesTests.cpp File Reference

Go to the source code of this file.

Classes

class  RFCRequestTest
 
class  RFCResponseTest
 

Typedefs

using RfcParam = std::pair< bool, vector< string >>
 

Functions

RfcParam d3 (false, exampleHex1)
 
RfcParam d4 (true, exampleHex2)
 
RfcParam d5 (false, exampleHex3)
 
RfcParam d6 (true, exampleHex4)
 
 TEST_P (RFCRequestTest, RfcExampleRequest)
 
 INSTANTIATE_TEST_CASE_P (Huffman, RFCRequestTest,::testing::Values(d3, d4))
 
 TEST_P (RFCResponseTest, RfcExampleResponse)
 
 INSTANTIATE_TEST_CASE_P (Huffman, RFCResponseTest,::testing::Values(d5, d6))
 

Variables

vector< stringexampleHex1
 
vector< stringexampleHex2
 
vector< stringexampleHex3
 
vector< stringexampleHex4
 

Typedef Documentation

using RfcParam = std::pair<bool, vector<string>>

Definition at line 26 of file RFCExamplesTests.cpp.

Function Documentation

RfcParam d3 ( false  ,
exampleHex1   
)

Referenced by TEST(), TEST_F(), and TEST_P().

RfcParam d4 ( true  ,
exampleHex2   
)

Referenced by TEST(), and TEST_P().

RfcParam d5 ( false  ,
exampleHex3   
)

Referenced by TEST(), and TEST_P().

RfcParam d6 ( true  ,
exampleHex4   
)

Referenced by TEST(), and TEST_P().

INSTANTIATE_TEST_CASE_P ( Huffman  ,
RFCRequestTest  ,
::testing::Values(d3, d4  
)

Referenced by TEST_P().

INSTANTIATE_TEST_CASE_P ( Huffman  ,
RFCResponseTest  ,
::testing::Values(d5, d6  
)
TEST_P ( RFCRequestTest  ,
RfcExampleRequest   
)

Definition at line 132 of file RFCExamplesTests.cpp.

References proxygen::HeaderTable::bytes(), d3(), d4(), encodeDecode(), EXPECT_EQ, folly::gen::first, proxygen::HPACKContext::getTable(), INSTANTIATE_TEST_CASE_P(), folly::IOBuf::moveToFbString(), proxygen::HeaderTable::size(), and folly::unhexlify().

132  {
133  HPACKEncoder encoder(GetParam().first);
134  HPACKDecoder decoder;
135  // first request
136  unique_ptr<IOBuf> encoded = hpack::encodeDecode(req1, encoder, decoder);
137  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[0]));
138  EXPECT_EQ(encoder.getTable().bytes(), 57);
139  EXPECT_EQ(encoder.getTable().size(), 1);
140 
141  // second request
142  encoded = hpack::encodeDecode(req2, encoder, decoder);
143  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[1]));
144  EXPECT_EQ(encoder.getTable().bytes(), 110);
145  EXPECT_EQ(encoder.getTable().size(), 2);
146 
147  // third request
148  encoded = hpack::encodeDecode(req3, encoder, decoder);
149  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[2]));
150  EXPECT_EQ(encoder.getTable().bytes(), 164);
151  EXPECT_EQ(encoder.getTable().size(), 3);
152 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fbstring moveToFbString()
Definition: IOBuf.cpp:968
void encodeDecode(vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
constexpr detail::First first
Definition: Base-inl.h:2553
TEST_P ( RFCResponseTest  ,
RfcExampleResponse   
)

Definition at line 160 of file RFCExamplesTests.cpp.

References proxygen::HeaderTable::bytes(), d5(), d6(), encodeDecode(), EXPECT_EQ, folly::gen::first, proxygen::HPACKHeaderName::get(), proxygen::HPACKContext::getHeader(), proxygen::HPACKContext::getTable(), INSTANTIATE_TEST_CASE_P(), folly::IOBuf::moveToFbString(), proxygen::HPACKHeader::name, proxygen::HeaderTable::size(), uint32_t, folly::unhexlify(), and proxygen::HPACKHeader::value.

160  {
161  // this test does some evictions
162  uint32_t tableSize = 256;
163  HPACKEncoder encoder(GetParam().first, tableSize);
164  HPACKDecoder decoder(tableSize);
165 
166  // first
167  unique_ptr<IOBuf> encoded = hpack::encodeDecode(resp1, encoder, decoder);
168  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[0]));
169  EXPECT_EQ(encoder.getTable().bytes(), 222);
170  EXPECT_EQ(encoder.getTable().size(), 4);
171  EXPECT_EQ(encoder.getHeader(64).name.get(), "cache-control");
172  EXPECT_EQ(encoder.getHeader(64).value, "private");
173 
174  // second
175  encoded = hpack::encodeDecode(resp2, encoder, decoder);
176  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[1]));
177  EXPECT_EQ(encoder.getTable().bytes(), 222);
178  EXPECT_EQ(encoder.getTable().size(), 4);
179 
180  // third
181  encoded = hpack::encodeDecode(resp3, encoder, decoder);
182  EXPECT_EQ(encoded->moveToFbString(), unhexlify(GetParam().second[2]));
183 
184  EXPECT_EQ(encoder.getTable().size(), 3);
185  EXPECT_EQ(encoder.getTable().bytes(), 215);
186 }
bool unhexlify(const InputString &input, OutputString &output)
Definition: String-inl.h:616
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fbstring moveToFbString()
Definition: IOBuf.cpp:968
void encodeDecode(vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
constexpr detail::First first
Definition: Base-inl.h:2553

Variable Documentation

vector<string> exampleHex1
Initial value:
= {
"828684410f7777772e6578616d706c652e636f6d",
"828684be58086e6f2d6361636865",
"828785bf400a637573746f6d2d6b65790c637573746f6d2d76616c7565"
}

Definition at line 87 of file RFCExamplesTests.cpp.

vector<string> exampleHex2
Initial value:
= {
"828684418cf1e3c2e5f23a6ba0ab90f4ff",
"828684be5886a8eb10649cbf",
"828785bf408825a849e95ba97d7f8925a849e95bb8e8b4bf"
}

Definition at line 93 of file RFCExamplesTests.cpp.

vector<string> exampleHex3
Initial value:
= {
"4803333032580770726976617465611d4d6f6e2c203231204f63742032303133"
"2032303a31333a323120474d546e1768747470733a2f2f7777772e6578616d70"
"6c652e636f6d",
"4803333037c1c0bf",
"88c1611d4d6f6e2c203231204f637420323031332032303a31333a323220474d"
"54c05a04677a69707738666f6f3d4153444a4b48514b425a584f5157454f5049"
"5541585157454f49553b206d61782d6167653d333630303b2076657273696f6e"
"3d31"
}

Definition at line 102 of file RFCExamplesTests.cpp.

vector<string> exampleHex4
Initial value:
= {
"488264025885aec3771a4b6196d07abe941054d444a8200595040b8166e082a6"
"2d1bff6e919d29ad171863c78f0b97c8e9ae82ae43d3",
"4883640effc1c0bf",
"88c16196d07abe941054d444a8200595040b8166e084a62d1bffc05a839bd9ab"
"77ad94e7821dd7f2e6c7b335dfdfcd5b3960d5af27087f3672c1ab270fb5291f"
"9587316065c003ed4ee5b1063d5007"
}

Definition at line 112 of file RFCExamplesTests.cpp.