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

Side by Side Diff: base/files/file_path_unittest.cc

Issue 1836923002: Handle invalid CFStrings in GetHFSDecomposedForm() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 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 unified diff | Download patch
« no previous file with comments | « base/files/file_path.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1288
1289 // Test the PrintTo overload for FilePath (used when a test fails to compare two 1289 // Test the PrintTo overload for FilePath (used when a test fails to compare two
1290 // FilePaths). 1290 // FilePaths).
1291 TEST_F(FilePathTest, PrintTo) { 1291 TEST_F(FilePathTest, PrintTo) {
1292 std::stringstream ss; 1292 std::stringstream ss;
1293 FilePath fp(FPL("foo")); 1293 FilePath fp(FPL("foo"));
1294 base::PrintTo(fp, &ss); 1294 base::PrintTo(fp, &ss);
1295 EXPECT_EQ("foo", ss.str()); 1295 EXPECT_EQ("foo", ss.str());
1296 } 1296 }
1297 1297
1298 // Test GetHFSDecomposedForm should return empty result for invalid UTF-8
1299 // strings.
1300 #if defined(OS_MACOSX)
1301 TEST_F(FilePathTest, GetHFSDecomposedFormWithInvalidInput) {
1302 const FilePath::CharType* cases[] = {
1303 FPL("\xc3\x28"),
1304 FPL("\xe2\x82\x28"),
1305 FPL("\xe2\x28\xa1"),
1306 FPL("\xf0\x28\x8c\xbc"),
1307 FPL("\xf0\x28\x8c\x28"),
1308 };
1309 for (const auto& invalid_input : cases) {
1310 FilePath::StringType observed = FilePath::GetHFSDecomposedForm(
1311 invalid_input);
1312 EXPECT_TRUE(observed.empty());
1313 }
1314 }
1315 #endif
1316
1298 } // namespace base 1317 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_path.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698