31 #include <google/protobuf/compiler/annotation_test_util.h>
36 #include <google/protobuf/testing/file.h>
37 #include <google/protobuf/testing/file.h>
38 #include <google/protobuf/compiler/code_generator.h>
39 #include <google/protobuf/compiler/command_line_interface.h>
40 #include <google/protobuf/io/printer.h>
41 #include <google/protobuf/io/zero_copy_stream.h>
42 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
43 #include <google/protobuf/descriptor.pb.h>
44 #include <google/protobuf/testing/googletest.h>
45 #include <gtest/gtest.h>
50 namespace annotation_test_util {
81 cli->SetInputsAreProtoPathRelative(
true);
83 DescriptorCapturingGenerator capturing_generator(
file);
84 cli->RegisterGenerator(
"--capture_out", &capturing_generator,
"");
89 const char* argv[] = {
"protoc", proto_path.c_str(),
90 plugin_specific_args.c_str(), capture_out.c_str(),
93 return cli->Run(5, argv) == 0;
100 return info->ParseFromZeroCopyStream(&
input);
105 const std::vector<int>&
path,
106 std::vector<const GeneratedCodeInfo::Annotation*>* annotations) {
114 for (; node <
path.size(); ++node) {
115 if (annotation->
path(node) !=
path[node]) {
119 if (node ==
path.size()) {
120 annotations->push_back(annotation);
127 const std::vector<int>&
path) {
128 std::vector<const GeneratedCodeInfo::Annotation*> annotations;
130 if (annotations.empty()) {
133 return annotations[0];
138 const std::vector<const GeneratedCodeInfo::Annotation*>& annotations,
140 for (std::vector<const GeneratedCodeInfo::Annotation*>::const_iterator
141 i = annotations.begin(),
142 e = annotations.end();
147 if (end < begin || end > file_content.size()) {
150 if (file_content.substr(
begin,
end -
begin) == expected_text) {
160 std::vector<const GeneratedCodeInfo::Annotation*> annotations;
161 annotations.push_back(annotation);