Index: base/files/file_path_unittest.cc |
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc |
index f57de67911a2af81689bb382f2f1a59445f695a6..a091e62dd1b4fd7b8c4b2633db41606897d9081b 100644 |
--- a/base/files/file_path_unittest.cc |
+++ b/base/files/file_path_unittest.cc |
@@ -1295,4 +1295,23 @@ TEST_F(FilePathTest, PrintTo) { |
EXPECT_EQ("foo", ss.str()); |
} |
+// Test GetHFSDecomposedForm should return empty result for invalid UTF-8 |
+// strings. |
+#if defined(OS_MACOSX) |
+TEST_F(FilePathTest, GetHFSDecomposedFormWithInvalidInput) { |
+ const FilePath::CharType* cases[] = { |
+ FPL("\xc3\x28"), |
+ FPL("\xe2\x82\x28"), |
+ FPL("\xe2\x28\xa1"), |
+ FPL("\xf0\x28\x8c\xbc"), |
+ FPL("\xf0\x28\x8c\x28"), |
+ }; |
+ for (const auto& invalid_input : cases) { |
+ FilePath::StringType observed = FilePath::GetHFSDecomposedForm( |
+ invalid_input); |
+ EXPECT_TRUE(observed.empty()); |
+ } |
+} |
+#endif |
+ |
} // namespace base |