proxygen
TestUtil.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/io/IOBuf.h>
13 #include <memory>
19 #include <string>
20 
21 namespace proxygen { namespace hpack {
22 
23 void dumpToFile(const std::string& filename, const folly::IOBuf* buf);
24 
25 std::unique_ptr<folly::IOBuf> encodeDecode(
26  std::vector<HPACKHeader>& headers,
27  HPACKEncoder& encoder,
28  HPACKDecoder& decoder);
29 
30 void encodeDecode(
31  std::vector<HPACKHeader>& headers,
32  QPACKEncoder& encoder,
33  QPACKDecoder& decoder);
34 
35 
36 std::unique_ptr<HPACKDecoder::headers_t> decode(HPACKDecoder& decoder,
37  const folly::IOBuf* buffer);
38 
39 std::vector<compress::Header> headersFromArray(
40  std::vector<std::vector<std::string>>& a);
41 
42 std::vector<compress::Header> basicHeaders();
43 
45 
46  public:
48  : type_(type) {}
49 
51  EXPECT_EQ(type, type_);
52  encodes++;
55  }
56 
58  EXPECT_EQ(type, type_);
59  decodes++;
62  }
63 
65  EXPECT_EQ(type, type_);
66  errors++;
67  }
68 
70  EXPECT_EQ(type, type_);
71  tooLarge++;
72  }
73 
74  void reset() {
75  encodes = 0;
76  decodes = 0;
81  errors = 0;
82  tooLarge = 0;
83  }
84 
94 };
95 
96 }}
unique_ptr< IOBuf > encodeDecode(vector< HPACKHeader > &headers, HPACKEncoder &encoder, HPACKDecoder &decoder)
Definition: TestUtil.cpp:55
std::vector< uint8_t > buffer(kBufferSize+16)
void recordEncode(HeaderCodec::Type type, HTTPHeaderSize &size) override
Definition: TestUtil.h:50
vector< compress::Header > basicHeaders()
Definition: TestUtil.cpp:116
PskType type
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TestHeaderCodecStats(HeaderCodec::Type type)
Definition: TestUtil.h:47
vector< compress::Header > headersFromArray(vector< vector< string >> &a)
Definition: TestUtil.cpp:108
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void recordDecodeTooLarge(HeaderCodec::Type type) override
Definition: TestUtil.h:69
void recordDecode(HeaderCodec::Type type, HTTPHeaderSize &size) override
Definition: TestUtil.h:57
unique_ptr< HPACKDecoder::headers_t > decode(HPACKDecoder &decoder, const IOBuf *buffer)
Definition: TestUtil.cpp:95
char a
void dumpToFile(const string &filename, const IOBuf *buf)
Definition: TestUtil.cpp:27
const char * string
Definition: Conv.cpp:212
void recordDecodeError(HeaderCodec::Type type) override
Definition: TestUtil.h:64