| Index: third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| index 0e35ed19c3bc9df2e6be95987a8ab298514c7988..98261431db991dad136d30db5096dfb5c658e214 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -32,6 +32,11 @@
|
|
|
| #include <google/protobuf/compiler/mock_code_generator.h>
|
|
|
| +#include <memory>
|
| +#ifndef _SHARED_PTR_H
|
| +#include <google/protobuf/stubs/shared_ptr.h>
|
| +#endif
|
| +
|
| #include <google/protobuf/testing/file.h>
|
| #include <google/protobuf/descriptor.pb.h>
|
| #include <google/protobuf/descriptor.h>
|
| @@ -53,7 +58,7 @@ string CommaSeparatedList(const vector<const FileDescriptor*> all_files) {
|
| for (int i = 0; i < all_files.size(); i++) {
|
| names.push_back(all_files[i]->name());
|
| }
|
| - return JoinStrings(names, ",");
|
| + return Join(names, ",");
|
| }
|
|
|
| static const char* kFirstInsertionPointName = "first_mock_insertion_point";
|
| @@ -77,11 +82,11 @@ void MockCodeGenerator::ExpectGenerated(
|
| const string& first_parsed_file_name,
|
| const string& output_directory) {
|
| string content;
|
| - ASSERT_TRUE(File::ReadFileToString(
|
| - output_directory + "/" + GetOutputFileName(name, file), &content));
|
| + GOOGLE_CHECK_OK(
|
| + File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
|
| + &content, true));
|
|
|
| - vector<string> lines;
|
| - SplitStringUsing(content, "\n", &lines);
|
| + vector<string> lines = Split(content, "\n", true);
|
|
|
| while (!lines.empty() && lines.back().empty()) {
|
| lines.pop_back();
|
| @@ -95,7 +100,7 @@ void MockCodeGenerator::ExpectGenerated(
|
| SplitStringUsing(insertions, ",", &insertion_list);
|
| }
|
|
|
| - ASSERT_EQ(lines.size(), 3 + insertion_list.size() * 2);
|
| + EXPECT_EQ(lines.size(), 3 + insertion_list.size() * 2);
|
| EXPECT_EQ(GetOutputFileContent(name, parameter, file,
|
| first_parsed_file_name, first_message_name),
|
| lines[0]);
|
| @@ -128,10 +133,10 @@ bool MockCodeGenerator::Generate(
|
| *error = "Saw message type MockCodeGenerator_Error.";
|
| return false;
|
| } else if (command == "Exit") {
|
| - cerr << "Saw message type MockCodeGenerator_Exit." << endl;
|
| + std::cerr << "Saw message type MockCodeGenerator_Exit." << std::endl;
|
| exit(123);
|
| } else if (command == "Abort") {
|
| - cerr << "Saw message type MockCodeGenerator_Abort." << endl;
|
| + std::cerr << "Saw message type MockCodeGenerator_Abort." << std::endl;
|
| abort();
|
| } else if (command == "HasSourceCodeInfo") {
|
| FileDescriptorProto file_descriptor_proto;
|
| @@ -139,8 +144,8 @@ bool MockCodeGenerator::Generate(
|
| bool has_source_code_info =
|
| file_descriptor_proto.has_source_code_info() &&
|
| file_descriptor_proto.source_code_info().location_size() > 0;
|
| - cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: "
|
| - << has_source_code_info << "." << endl;
|
| + std::cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: "
|
| + << has_source_code_info << "." << std::endl;
|
| abort();
|
| } else {
|
| GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command;
|
| @@ -155,10 +160,8 @@ bool MockCodeGenerator::Generate(
|
|
|
| for (int i = 0; i < insert_into.size(); i++) {
|
| {
|
| - scoped_ptr<io::ZeroCopyOutputStream> output(
|
| - context->OpenForInsert(
|
| - GetOutputFileName(insert_into[i], file),
|
| - kFirstInsertionPointName));
|
| + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->OpenForInsert(
|
| + GetOutputFileName(insert_into[i], file), kFirstInsertionPointName));
|
| io::Printer printer(output.get(), '$');
|
| printer.PrintRaw(GetOutputFileContent(name_, "first_insert",
|
| file, context));
|
| @@ -169,10 +172,9 @@ bool MockCodeGenerator::Generate(
|
| }
|
|
|
| {
|
| - scoped_ptr<io::ZeroCopyOutputStream> output(
|
| - context->OpenForInsert(
|
| - GetOutputFileName(insert_into[i], file),
|
| - kSecondInsertionPointName));
|
| + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
|
| + context->OpenForInsert(GetOutputFileName(insert_into[i], file),
|
| + kSecondInsertionPointName));
|
| io::Printer printer(output.get(), '$');
|
| printer.PrintRaw(GetOutputFileContent(name_, "second_insert",
|
| file, context));
|
| @@ -183,7 +185,7 @@ bool MockCodeGenerator::Generate(
|
| }
|
| }
|
| } else {
|
| - scoped_ptr<io::ZeroCopyOutputStream> output(
|
| + google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
|
| context->Open(GetOutputFileName(name_, file)));
|
|
|
| io::Printer printer(output.get(), '$');
|
|
|