summaryrefslogtreecommitdiffstats
path: root/base/file_util_unittest.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 17:32:18 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-19 17:32:18 +0000
commitb988fe4ded9067b2e5cb7e3a3937036ce2cb09c8 (patch)
tree161d268af247aa38b015c3ca844ec6ffe6dbe526 /base/file_util_unittest.cc
parent1692a966a15bfce0bcf9a21b548d8bdb46edcfc2 (diff)
downloadchromium_src-b988fe4ded9067b2e5cb7e3a3937036ce2cb09c8.zip
chromium_src-b988fe4ded9067b2e5cb7e3a3937036ce2cb09c8.tar.gz
chromium_src-b988fe4ded9067b2e5cb7e3a3937036ce2cb09c8.tar.bz2
Fixes bug in file_util::ReplaceExtension that could chop off path
elements. This was causing some folks bookmarks not to get saved! BUG=1946 TEST=covered by unit tests Review URL: http://codereview.chromium.org/2990 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_unittest.cc')
-rw-r--r--base/file_util_unittest.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index e5cea3a..c56579a 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -819,6 +819,18 @@ TEST_F(FileUtilTest, ReplaceExtensionTest) {
}
}
+// Make sure ReplaceExtension doesn't replace an extension that occurs as one of
+// the directory names of the path.
+TEST_F(FileUtilTest, ReplaceExtensionTestWithPathSeparators) {
+ std::wstring path;
+ file_util::AppendToPath(&path, L"foo.bar");
+ file_util::AppendToPath(&path, L"foo");
+ // '/foo.bar/foo' with extension '.baz'
+ std::wstring result_path = path;
+ file_util::ReplaceExtension(&result_path, L".baz");
+ EXPECT_EQ(path + L".baz", result_path);
+}
+
TEST_F(FileUtilTest, FileEnumeratorTest) {
// Test an empty directory.
file_util::FileEnumerator f0(test_dir_, true,