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 " | |
103 "generate_descriptor_proto.sh. Then add this file " | 102 "generate_descriptor_proto.sh. Then add this file " |
104 "to your CL."; | 103 "to your CL."; |
105 } | 104 } |
106 | 105 |
107 // implements GeneratorContext -------------------------------------- | 106 // implements GeneratorContext -------------------------------------- |
108 | 107 |
109 virtual io::ZeroCopyOutputStream* Open(const string& filename) { | 108 virtual io::ZeroCopyOutputStream* Open(const string& filename) { |
110 string** map_slot = &files_[filename]; | 109 string** map_slot = &files_[filename]; |
111 delete *map_slot; | 110 delete *map_slot; |
112 *map_slot = new string; | 111 *map_slot = new string; |
113 | 112 |
114 return new io::StringOutputStream(*map_slot); | 113 return new io::StringOutputStream(*map_slot); |
115 } | 114 } |
116 | 115 |
117 private: | 116 private: |
118 map<string, string*> files_; | 117 std::map<string, string*> files_; |
119 }; | 118 }; |
120 | 119 |
121 TEST(BootstrapTest, GeneratedDescriptorMatches) { | 120 TEST(BootstrapTest, GeneratedDescriptorMatches) { |
122 MockErrorCollector error_collector; | 121 MockErrorCollector error_collector; |
123 DiskSourceTree source_tree; | 122 DiskSourceTree source_tree; |
124 source_tree.MapPath("", TestSourceDir()); | 123 source_tree.MapPath("", TestSourceDir()); |
125 Importer importer(&source_tree, &error_collector); | 124 Importer importer(&source_tree, &error_collector); |
126 const FileDescriptor* proto_file = | 125 const FileDescriptor* proto_file = |
127 importer.Import("google/protobuf/descriptor.proto"); | 126 importer.Import("google/protobuf/descriptor.proto"); |
128 const FileDescriptor* plugin_proto_file = | 127 const FileDescriptor* plugin_proto_file = |
(...skipping 21 matching lines...) Expand all Loading... |
150 context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", | 149 context.ExpectFileMatches("google/protobuf/compiler/plugin.pb.cc", |
151 "google/protobuf/compiler/plugin.pb.cc"); | 150 "google/protobuf/compiler/plugin.pb.cc"); |
152 } | 151 } |
153 | 152 |
154 } // namespace | 153 } // namespace |
155 | 154 |
156 } // namespace cpp | 155 } // namespace cpp |
157 } // namespace compiler | 156 } // namespace compiler |
158 } // namespace protobuf | 157 } // namespace protobuf |
159 } // namespace google | 158 } // namespace google |
OLD | NEW |