| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 string* expected_contents = FindPtrOrNull(files_, virtual_filename); | 92 string* expected_contents = FindPtrOrNull(files_, virtual_filename); |
| 93 ASSERT_TRUE(expected_contents != NULL) | 93 ASSERT_TRUE(expected_contents != NULL) |
| 94 << "Generator failed to generate file: " << virtual_filename; | 94 << "Generator failed to generate file: " << virtual_filename; |
| 95 | 95 |
| 96 string actual_contents; | 96 string actual_contents; |
| 97 GOOGLE_CHECK_OK( | 97 GOOGLE_CHECK_OK( |
| 98 File::GetContents(TestSourceDir() + "/" + physical_filename, | 98 File::GetContents(TestSourceDir() + "/" + physical_filename, |
| 99 &actual_contents, true)); | 99 &actual_contents, true)); |
| 100 EXPECT_TRUE(actual_contents == *expected_contents) | 100 EXPECT_TRUE(actual_contents == *expected_contents) |
| 101 << physical_filename << " needs to be regenerated. Please run " | 101 << physical_filename << " needs to be regenerated. Please run " |
| 102 "google/protobuf/compiler/release_compiler.sh and " |
| 102 "generate_descriptor_proto.sh. Then add this file " | 103 "generate_descriptor_proto.sh. Then add this file " |
| 103 "to your CL."; | 104 "to your CL."; |
| 104 } | 105 } |
| 105 | 106 |
| 106 // implements GeneratorContext -------------------------------------- | 107 // implements GeneratorContext -------------------------------------- |
| 107 | 108 |
| 108 virtual io::ZeroCopyOutputStream* Open(const string& filename) { | 109 virtual io::ZeroCopyOutputStream* Open(const string& filename) { |
| 109 string** map_slot = &files_[filename]; | 110 string** map_slot = &files_[filename]; |
| 110 delete *map_slot; | 111 delete *map_slot; |
| 111 *map_slot = new string; | 112 *map_slot = new string; |
| 112 | 113 |
| 113 return new io::StringOutputStream(*map_slot); | 114 return new io::StringOutputStream(*map_slot); |
| 114 } | 115 } |
| 115 | 116 |
| 116 private: | 117 private: |
| 117 std::map<string, string*> files_; | 118 map<string, string*> files_; |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 TEST(BootstrapTest, GeneratedDescriptorMatches) { | 121 TEST(BootstrapTest, GeneratedDescriptorMatches) { |
| 121 MockErrorCollector error_collector; | 122 MockErrorCollector error_collector; |
| 122 DiskSourceTree source_tree; | 123 DiskSourceTree source_tree; |
| 123 source_tree.MapPath("", TestSourceDir()); | 124 source_tree.MapPath("", TestSourceDir()); |
| 124 Importer importer(&source_tree, &error_collector); | 125 Importer importer(&source_tree, &error_collector); |
| 125 const FileDescriptor* proto_file = | 126 const FileDescriptor* proto_file = |
| 126 importer.Import("google/protobuf/descriptor.proto"); | 127 importer.Import("google/protobuf/descriptor.proto"); |
| 127 const FileDescriptor* plugin_proto_file = | 128 const FileDescriptor* plugin_proto_file = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 149 context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", | 150 context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", |
| 150 "google/protobuf/compiler/plugin.pb.cc"); | 151 "google/protobuf/compiler/plugin.pb.cc"); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace | 154 } // namespace |
| 154 | 155 |
| 155 } // namespace cpp | 156 } // namespace cpp |
| 156 } // namespace compiler | 157 } // namespace compiler |
| 157 } // namespace protobuf | 158 } // namespace protobuf |
| 158 } // namespace google | 159 } // namespace google |
| OLD | NEW |