MCPcopy Create free account
hub / github.com/DFHack/dfhack / TEST

Function TEST

depends/protobuf/google/protobuf/compiler/cpp/cpp_unittest.cc:98–122  ·  view source on GitHub ↗

Test that generated code has proper descriptors: Parse a descriptor directly (using google::protobuf::compiler::Importer) and compare it to the one that was produced by generated code.

Source from the content-addressed store, hash-verified

96// Parse a descriptor directly (using google::protobuf::compiler::Importer) and
97// compare it to the one that was produced by generated code.
98TEST(GeneratedDescriptorTest, IdenticalDescriptors) {
99 const FileDescriptor* generated_descriptor =
100 unittest::TestAllTypes::descriptor()->file();
101
102 // Set up the Importer.
103 MockErrorCollector error_collector;
104 DiskSourceTree source_tree;
105 source_tree.MapPath("", TestSourceDir());
106 Importer importer(&source_tree, &error_collector);
107
108 // Import (parse) unittest.proto.
109 const FileDescriptor* parsed_descriptor =
110 importer.Import("google/protobuf/unittest.proto");
111 EXPECT_EQ("", error_collector.text_);
112 ASSERT_TRUE(parsed_descriptor != NULL);
113
114 // Test that descriptors are generated correctly by converting them to
115 // FileDescriptorProtos and comparing.
116 FileDescriptorProto generated_decsriptor_proto, parsed_descriptor_proto;
117 generated_descriptor->CopyTo(&generated_decsriptor_proto);
118 parsed_descriptor->CopyTo(&parsed_descriptor_proto);
119
120 EXPECT_EQ(parsed_descriptor_proto.DebugString(),
121 generated_decsriptor_proto.DebugString());
122}
123
124#endif // !PROTOBUF_TEST_NO_DESCRIPTORS
125

Callers

nothing calls this directly

Calls 15

string_as_arrayFunction · 0.85
MapPathMethod · 0.80
ImportMethod · 0.80
operator=Method · 0.80
SerializeToStringMethod · 0.80
capacityMethod · 0.80
InternalIsFileLoadedMethod · 0.80
CopyToMethod · 0.45
DebugStringMethod · 0.45
ClearMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected