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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 void ExpectCannotOpenFile(const string& filename, | 286 void ExpectCannotOpenFile(const string& filename, |
287 const string& error_message) { | 287 const string& error_message) { |
288 google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_.Ope
n(filename)); | 288 google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_.Ope
n(filename)); |
289 EXPECT_TRUE(input == NULL); | 289 EXPECT_TRUE(input == NULL); |
290 EXPECT_EQ(error_message, source_tree_.GetLastErrorMessage()); | 290 EXPECT_EQ(error_message, source_tree_.GetLastErrorMessage()); |
291 } | 291 } |
292 | 292 |
293 DiskSourceTree source_tree_; | 293 DiskSourceTree source_tree_; |
294 | 294 |
295 // Paths of two on-disk directories to use during the test. | 295 // Paths of two on-disk directories to use during the test. |
296 std::vector<string> dirnames_; | 296 vector<string> dirnames_; |
297 }; | 297 }; |
298 | 298 |
299 TEST_F(DiskSourceTreeTest, MapRoot) { | 299 TEST_F(DiskSourceTreeTest, MapRoot) { |
300 // Test opening a file in a directory that is mapped to the root of the | 300 // Test opening a file in a directory that is mapped to the root of the |
301 // source tree. | 301 // source tree. |
302 AddFile(dirnames_[0] + "/foo", "Hello World!"); | 302 AddFile(dirnames_[0] + "/foo", "Hello World!"); |
303 source_tree_.MapPath("", dirnames_[0]); | 303 source_tree_.MapPath("", dirnames_[0]); |
304 | 304 |
305 ExpectFileContents("foo", "Hello World!"); | 305 ExpectFileContents("foo", "Hello World!"); |
306 ExpectCannotOpenFile("bar", "File not found."); | 306 ExpectCannotOpenFile("bar", "File not found."); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 // Accept NULL as output parameter. | 514 // Accept NULL as output parameter. |
515 EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", NULL)); | 515 EXPECT_TRUE(source_tree_.VirtualFileToDiskFile("bar/foo", NULL)); |
516 EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", NULL)); | 516 EXPECT_FALSE(source_tree_.VirtualFileToDiskFile("baz/foo", NULL)); |
517 } | 517 } |
518 | 518 |
519 } // namespace | 519 } // namespace |
520 | 520 |
521 } // namespace compiler | 521 } // namespace compiler |
522 } // namespace protobuf | 522 } // namespace protobuf |
523 } // namespace google | 523 } // namespace google |
OLD | NEW |