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

Unified Diff: base/file_util_unittest.cc

Issue 254333002: Make base::ReadFileToString() return false on I/O error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « base/file_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_unittest.cc
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 0d793918d681fafeaa2e52a289cd4ebbb8a7e94d..7d9bc16ca562de10b558fd7aebc9a8e14cc8bab2 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -2012,7 +2012,12 @@ TEST_F(FileUtilTest, ReadFileToString) {
FilePath file_path =
temp_dir_.path().Append(FILE_PATH_LITERAL("ReadFileToStringTest"));
+ FilePath file_path_dangerous =
+ temp_dir_.path().Append(FILE_PATH_LITERAL("..")).
+ Append(temp_dir_.path().BaseName()).
+ Append(FILE_PATH_LITERAL("ReadFileToStringTest"));
+ // Create test file.
ASSERT_EQ(4, WriteFile(file_path, kTestData, 4));
EXPECT_TRUE(ReadFileToString(file_path, &data));
@@ -2042,6 +2047,11 @@ TEST_F(FileUtilTest, ReadFileToString) {
EXPECT_TRUE(ReadFileToString(file_path, NULL));
+ data = "temp";
+ EXPECT_FALSE(ReadFileToString(file_path_dangerous, &data));
+ EXPECT_EQ(data.length(), 0u);
willchan no longer on Chromium 2014/04/30 15:14:40 Ordering is (expected, actual), so 0u should go fi
Thiemo Nagel 2014/04/30 16:11:33 Thank you! I was tricked into this by the surroun
+
+ // Delete test file.
EXPECT_TRUE(base::DeleteFile(file_path, false));
data = "temp";
« no previous file with comments | « base/file_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698