27 using namespace folly;
31 class StringAppender {
42 typedef GroupVarintEncoder<uint32_t, StringAppender> GroupVarint32Encoder;
43 typedef GroupVarintEncoder<uint64_t, StringAppender> GroupVarint64Encoder;
49 std::vector<char> expectedBytes;
51 while ((byte = va_arg(ap,
int)) != -1) {
52 expectedBytes.push_back(byte);
59 std::vector<char> foundBytes;
63 foundBytes.resize(std::max<size_t>(size + 4, 17UL));
64 char*
start = &(foundBytes.front());
66 EXPECT_EQ((
void*)(start + size), (
void*)p);
68 for (
size_t i = 0;
i <
size;
i++) {
69 EXPECT_EQ(0xff & expectedBytes[
i], 0xff & foundBytes[i]);
73 EXPECT_EQ(size, GroupVarint32::encodedSize(start));
77 EXPECT_EQ((
void*)(start + size), (
void*)r);
85 void testGroupVarint64(
94 std::vector<char> expectedBytes;
96 while ((byte = va_arg(ap,
int)) != -1) {
97 expectedBytes.push_back(byte);
104 std::vector<char> foundBytes;
105 foundBytes.resize(size + 8);
106 char* start = &(foundBytes.front());
108 EXPECT_EQ((
void*)(start + size), (
void*)p);
110 for (
size_t i = 0;
i <
size;
i++) {
111 EXPECT_EQ(0xff & expectedBytes[
i], 0xff & foundBytes[i]);
115 EXPECT_EQ(size, GroupVarint64::encodedSize(start));
119 EXPECT_EQ((
void*)(start + size), (
void*)r);
134 EXPECT_EQ(13, GroupVarint32::maxSize(3));
135 EXPECT_EQ(17, GroupVarint32::maxSize(4));
136 EXPECT_EQ(22, GroupVarint32::maxSize(5));
137 EXPECT_EQ(26, GroupVarint32::maxSize(6));
146 1 << 8, (2 << 16) + 3, (4 << 24) + (5 << 8) + 6, 7,
147 0x39, 0, 1, 3, 0, 2, 6, 5, 0, 4, 7, -1);
153 EXPECT_EQ(10, GroupVarint64::maxSize(1));
154 EXPECT_EQ(18, GroupVarint64::maxSize(2));
155 EXPECT_EQ(26, GroupVarint64::maxSize(3));
156 EXPECT_EQ(34, GroupVarint64::maxSize(4));
157 EXPECT_EQ(42, GroupVarint64::maxSize(5));
158 EXPECT_EQ(52, GroupVarint64::maxSize(6));
162 0, 0, 0, 0, 0, 0, 0, -1);
165 0, 0, 1, 2, 3, 4, 5, -1);
167 1 << 8, (2 << 16) + 3, (4 << 24) + (5 << 8) + 6,
168 (7ULL << 32) + (8 << 16),
169 (9ULL << 56) + (10ULL << 40) + 11,
175 11, 0, 0, 0, 0, 10, 0, 9,
183 GroupVarint32Encoder gv(s);
191 GroupVarint32Encoder gv(s);
211 GroupVarint32Decoder gv(p);
220 std::string s(
"\x00\x01\x02\x03\x04\x01\x02\x03\x04", 9);
224 GroupVarint32Decoder gv(p);
244 std::string s(
"\x00\x01\x02\x03\x04\x01\x02\x03\x04", 9);
248 GroupVarint32Decoder gv(p, 3);
262 std::string s(
"\x00\x01\x02\x03\x04\x01\x02\x03\x04", 9);
266 GroupVarint32Decoder gv(p, 5);
unique_ptr< IOBuf > encode(vector< HPACKHeader > &headers, HPACKEncoder &encoder)
#define EXPECT_EQ(val1, val2)
TokenBindingMessage decode(folly::io::Cursor &cursor)
constexpr size_type size() const
—— Concurrent Priority Queue Implementation ——
constexpr auto size(C const &c) -> decltype(c.size())
constexpr Iter data() const
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)