Upgrade linux protobuf
This commit is contained in:
1 parent
79f2f356d5
commit
0f3130fb47
689 files changed
+141922
-132057
No files matched your search
@@ -36,13 +36,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <google/protobuf/testing/file.h>
|
||||
#include <google/protobuf/testing/file.h>
|
||||
#include <google/protobuf/compiler/cpp/cpp_generator.h>
|
||||
#include <google/protobuf/compiler/command_line_interface.h>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
#include <google/protobuf/io/printer.h>
|
||||
|
||||
#include <google/protobuf/testing/file.h>
|
||||
#include <google/protobuf/testing/file.h>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
#include <google/protobuf/testing/googletest.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -58,9 +57,8 @@ class TestGenerator : public CodeGenerator {
|
||||
~TestGenerator() {}
|
||||
|
||||
virtual bool Generate(const FileDescriptor* file,
|
||||
const string& parameter,
|
||||
GeneratorContext* context,
|
||||
string* error) const {
|
||||
const std::string& parameter, GeneratorContext* context,
|
||||
std::string* error) const {
|
||||
TryInsert("test.pb.h", "includes", context);
|
||||
TryInsert("test.pb.h", "namespace_scope", context);
|
||||
TryInsert("test.pb.h", "global_scope", context);
|
||||
@@ -82,13 +80,9 @@ class TestGenerator : public CodeGenerator {
|
||||
// Check field accessors for a required string:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_set:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_mutable:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_set_allocated:foo.Bar.requiredString",
|
||||
context);
|
||||
TryInsert("test.pb.h", "field_set_char:foo.Bar.requiredString", context);
|
||||
TryInsert("test.pb.h", "field_set_pointer:foo.Bar.requiredString", context);
|
||||
|
||||
// Check field accessors for a repeated string:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.repeatedString", context);
|
||||
@@ -106,12 +100,8 @@ class TestGenerator : public CodeGenerator {
|
||||
// Check field accessors for a string inside oneof{}:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set_allocated:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set_char:foo.Bar.oneOfString", context);
|
||||
TryInsert("test.pb.h", "field_set_pointer:foo.Bar.oneOfString", context);
|
||||
|
||||
// Check field accessors for an optional message:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.optMessage", context);
|
||||
@@ -129,7 +119,8 @@ class TestGenerator : public CodeGenerator {
|
||||
// Check field accessors for a message inside oneof{}:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.oneOfMessage", context);
|
||||
TryInsert("test.pb.h", "field_mutable:foo.Bar.oneOfMessage", context);
|
||||
TryInsert("test.pb.cc", "field_set_allocated:foo.Bar.oneOfMessage", context);
|
||||
TryInsert("test.pb.cc", "field_set_allocated:foo.Bar.oneOfMessage",
|
||||
context);
|
||||
|
||||
// Check field accessors for an optional enum:
|
||||
TryInsert("test.pb.h", "field_get:foo.Bar.optEnum", context);
|
||||
@@ -167,7 +158,8 @@ class TestGenerator : public CodeGenerator {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TryInsert(const string& filename, const string& insertion_point,
|
||||
void TryInsert(const std::string& filename,
|
||||
const std::string& insertion_point,
|
||||
GeneratorContext* context) const {
|
||||
std::unique_ptr<io::ZeroCopyOutputStream> output(
|
||||
context->OpenForInsert(filename, insertion_point));
|
||||
@@ -219,7 +211,7 @@ TEST(CppPluginTest, PluginTest) {
|
||||
"}\n",
|
||||
true));
|
||||
|
||||
google::protobuf::compiler::CommandLineInterface cli;
|
||||
CommandLineInterface cli;
|
||||
cli.SetInputsAreProtoPathRelative(true);
|
||||
|
||||
CppGenerator cpp_generator;
|
||||
@@ -227,17 +219,12 @@ TEST(CppPluginTest, PluginTest) {
|
||||
cli.RegisterGenerator("--cpp_out", &cpp_generator, "");
|
||||
cli.RegisterGenerator("--test_out", &test_generator, "");
|
||||
|
||||
string proto_path = "-I" + TestTempDir();
|
||||
string cpp_out = "--cpp_out=" + TestTempDir();
|
||||
string test_out = "--test_out=" + TestTempDir();
|
||||
std::string proto_path = "-I" + TestTempDir();
|
||||
std::string cpp_out = "--cpp_out=" + TestTempDir();
|
||||
std::string test_out = "--test_out=" + TestTempDir();
|
||||
|
||||
const char* argv[] = {
|
||||
"protoc",
|
||||
proto_path.c_str(),
|
||||
cpp_out.c_str(),
|
||||
test_out.c_str(),
|
||||
"test.proto"
|
||||
};
|
||||
const char* argv[] = {"protoc", proto_path.c_str(), cpp_out.c_str(),
|
||||
test_out.c_str(), "test.proto"};
|
||||
|
||||
EXPECT_EQ(0, cli.Run(5, argv));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user