MCPcopy Create free account
hub / github.com/apache/brpc / TEST_F

Function TEST_F

test/brpc_hpack_unittest.cpp:30–58  ·  view source on GitHub ↗

Copied test cases from example of rfc7541

Source from the content-addressed store, hash-verified

28
29// Copied test cases from example of rfc7541
30TEST_F(HPackTest, header_with_indexing) {
31 brpc::HPacker p1;
32 ASSERT_EQ(0, p1.Init(4096));
33 brpc::HPacker p2;
34 ASSERT_EQ(0, p2.Init(4096));
35 brpc::HPacker::Header h;
36 h.name = "Custom-Key";
37 h.value = "custom-header";
38 brpc::HPackOptions options;
39 options.index_policy = brpc::HPACK_INDEX_HEADER;
40 butil::IOBufAppender buf;
41 p1.Encode(&buf, h, options);
42 const ssize_t nwrite = buf.buf().size();
43 LOG(INFO) << butil::ToPrintable(buf.buf());
44 uint8_t expected[] = {
45 0x40, 0x0a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x6b, 0x65, 0x79,
46 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2d, 0x68, 0x65, 0x61, 0x64,
47 0x65, 0x72};
48 butil::StringPiece sp((char*)expected, sizeof(expected));
49 ASSERT_TRUE(buf.buf().equals(sp));
50 brpc::HPacker::Header h2;
51 ssize_t nread = p2.Decode(&buf.buf(), &h2);
52 ASSERT_EQ(nread, nwrite);
53 ASSERT_TRUE(buf.buf().empty());
54 std::string lowercase_name = h.name;
55 brpc::tolower(&lowercase_name);
56 ASSERT_EQ(lowercase_name, h2.name);
57 ASSERT_EQ(h.value, h2.value);
58}
59
60TEST_F(HPackTest, header_without_indexing) {
61 brpc::HPacker p1;

Callers

nothing calls this directly

Calls 9

ToPrintableClass · 0.85
tolowerFunction · 0.85
bufMethod · 0.80
equalsMethod · 0.80
InitMethod · 0.45
EncodeMethod · 0.45
sizeMethod · 0.45
DecodeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected