Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/mock_code_generator.cc

Issue 1322483002: Revert https://codereview.chromium.org/1291903002 (protobuf roll). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 98261431db991dad136d30db5096dfb5c658e214..0e35ed19c3bc9df2e6be95987a8ab298514c7988 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.
-// https://developers.google.com/protocol-buffers/
+// http://code.google.com/p/protobuf/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -32,11 +32,6 @@
#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>
@@ -58,7 +53,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 Join(names, ",");
+ return JoinStrings(names, ",");
}
static const char* kFirstInsertionPointName = "first_mock_insertion_point";
@@ -82,11 +77,11 @@ void MockCodeGenerator::ExpectGenerated(
const string& first_parsed_file_name,
const string& output_directory) {
string content;
- GOOGLE_CHECK_OK(
- File::GetContents(output_directory + "/" + GetOutputFileName(name, file),
- &content, true));
+ ASSERT_TRUE(File::ReadFileToString(
+ output_directory + "/" + GetOutputFileName(name, file), &content));
- vector<string> lines = Split(content, "\n", true);
+ vector<string> lines;
+ SplitStringUsing(content, "\n", &lines);
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
@@ -100,7 +95,7 @@ void MockCodeGenerator::ExpectGenerated(
SplitStringUsing(insertions, ",", &insertion_list);
}
- EXPECT_EQ(lines.size(), 3 + insertion_list.size() * 2);
+ ASSERT_EQ(lines.size(), 3 + insertion_list.size() * 2);
EXPECT_EQ(GetOutputFileContent(name, parameter, file,
first_parsed_file_name, first_message_name),
lines[0]);
@@ -133,10 +128,10 @@ bool MockCodeGenerator::Generate(
*error = "Saw message type MockCodeGenerator_Error.";
return false;
} else if (command == "Exit") {
- std::cerr << "Saw message type MockCodeGenerator_Exit." << std::endl;
+ cerr << "Saw message type MockCodeGenerator_Exit." << endl;
exit(123);
} else if (command == "Abort") {
- std::cerr << "Saw message type MockCodeGenerator_Abort." << std::endl;
+ cerr << "Saw message type MockCodeGenerator_Abort." << endl;
abort();
} else if (command == "HasSourceCodeInfo") {
FileDescriptorProto file_descriptor_proto;
@@ -144,8 +139,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;
- std::cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: "
- << has_source_code_info << "." << std::endl;
+ cerr << "Saw message type MockCodeGenerator_HasSourceCodeInfo: "
+ << has_source_code_info << "." << endl;
abort();
} else {
GOOGLE_LOG(FATAL) << "Unknown MockCodeGenerator command: " << command;
@@ -160,8 +155,10 @@ bool MockCodeGenerator::Generate(
for (int i = 0; i < insert_into.size(); i++) {
{
- google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->OpenForInsert(
- GetOutputFileName(insert_into[i], file), kFirstInsertionPointName));
+ 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));
@@ -172,9 +169,10 @@ bool MockCodeGenerator::Generate(
}
{
- google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
- context->OpenForInsert(GetOutputFileName(insert_into[i], file),
- kSecondInsertionPointName));
+ 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));
@@ -185,7 +183,7 @@ bool MockCodeGenerator::Generate(
}
}
} else {
- google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(
+ scoped_ptr<io::ZeroCopyOutputStream> output(
context->Open(GetOutputFileName(name_, file)));
io::Printer printer(output.get(), '$');

Powered by Google App Engine
This is Rietveld 408576698