diff options
author | jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2014-07-18 00:47:59 +0000 |
---|---|---|
committer | jieluo@google.com <jieluo@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2014-07-18 00:47:59 +0000 |
commit | 4de8f55113007fdc8e34107950e605fc0209d465 (patch) | |
tree | 92b7da8757a7740d9e1f2d3ead233542947d8c8c /src/google/protobuf/compiler/mock_code_generator.cc | |
parent | c5553a3d18f80132b9079c5504bc0aa1f7f950a0 (diff) |
down integrate to svn
Diffstat (limited to 'src/google/protobuf/compiler/mock_code_generator.cc')
-rw-r--r-- | src/google/protobuf/compiler/mock_code_generator.cc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/google/protobuf/compiler/mock_code_generator.cc b/src/google/protobuf/compiler/mock_code_generator.cc index 0e35ed19..1f91817f 100644 --- a/src/google/protobuf/compiler/mock_code_generator.cc +++ b/src/google/protobuf/compiler/mock_code_generator.cc @@ -32,6 +32,8 @@ #include <google/protobuf/compiler/mock_code_generator.h> +#include <memory> + #include <google/protobuf/testing/file.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> @@ -53,7 +55,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 +79,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 +97,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]); @@ -155,10 +157,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)); + 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)); @@ -170,9 +170,8 @@ bool MockCodeGenerator::Generate( { scoped_ptr<io::ZeroCopyOutputStream> output( - context->OpenForInsert( - GetOutputFileName(insert_into[i], file), - kSecondInsertionPointName)); + context->OpenForInsert(GetOutputFileName(insert_into[i], file), + kSecondInsertionPointName)); io::Printer printer(output.get(), '$'); printer.PrintRaw(GetOutputFileContent(name_, "second_insert", file, context)); |