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

Function TEST

test/brpc_proto_unittest.cpp:45–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45TEST(ProtoTest, proto) {
46 policy::RpcMeta meta;
47 const Descriptor *desc = meta.GetDescriptor();
48 const FileDescriptor *file_desc = desc->file();
49 DescriptorPool pool;
50 DynamicMessageFactory factory(&pool);
51 BuildDependency(file_desc, &pool);
52 FileDescriptorProto file_desc_proto;
53 file_desc->CopyTo(&file_desc_proto);
54 const FileDescriptor *new_file_desc = pool.BuildFile(file_desc_proto);
55 ASSERT_TRUE(new_file_desc != NULL);
56 const Descriptor *new_desc = new_file_desc->FindMessageTypeByName(desc->name());
57 ASSERT_TRUE(new_desc != NULL);
58 meta.set_correlation_id(123);
59 std::string data;
60 ASSERT_TRUE(meta.SerializeToString(&data));
61 Message *msg = factory.GetPrototype(new_desc)->New();
62 ASSERT_TRUE(msg != NULL);
63 ASSERT_TRUE(msg->ParseFromString(data));
64 ASSERT_TRUE(msg->SerializeToString(&data));
65 policy::RpcMeta new_meta;
66 ASSERT_TRUE(new_meta.ParseFromString(data));
67 ASSERT_EQ(123, new_meta.correlation_id());
68}
69
70TEST(ProtoTest, required_enum) {
71 test::Message1 msg1;

Callers

nothing calls this directly

Calls 8

BuildDependencyFunction · 0.85
fileMethod · 0.80
set_correlation_idMethod · 0.80
correlation_idMethod · 0.80
statMethod · 0.80
GetDescriptorMethod · 0.45
nameMethod · 0.45
NewMethod · 0.45

Tested by

no test coverage detected