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

Side by Side Diff: base/file_util_unittest.cc

Issue 147038: Pass through non-character codepoints in UTF-8,16,32 and Wide conversion func... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/string_util.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 std::wstring good_name; 832 std::wstring good_name;
833 } kIllegalCharacterCases[] = { 833 } kIllegalCharacterCases[] = {
834 {L"bad*file:name?.jpg", L"bad-file-name-.jpg"}, 834 {L"bad*file:name?.jpg", L"bad-file-name-.jpg"},
835 {L"**********::::.txt", L"--------------.txt"}, 835 {L"**********::::.txt", L"--------------.txt"},
836 // We can't use UCNs (universal character names) for C0/C1 characters and 836 // We can't use UCNs (universal character names) for C0/C1 characters and
837 // U+007F, but \x escape is interpreted by MSVC and gcc as we intend. 837 // U+007F, but \x escape is interpreted by MSVC and gcc as we intend.
838 {L"bad\x0003\x0091 file\u200E\u200Fname.png", L"bad-- file--name.png"}, 838 {L"bad\x0003\x0091 file\u200E\u200Fname.png", L"bad-- file--name.png"},
839 #if defined(OS_WIN) 839 #if defined(OS_WIN)
840 {L"bad*file\\name.jpg", L"bad-file-name.jpg"}, 840 {L"bad*file\\name.jpg", L"bad-file-name.jpg"},
841 {L"\t bad*file\\name/.jpg ", L"bad-file-name-.jpg"}, 841 {L"\t bad*file\\name/.jpg ", L"bad-file-name-.jpg"},
842 {L"bad\uFFFFfile\U0010FFFEname.jpg ", L"bad-file-name.jpg"},
843 #elif defined(OS_POSIX) 842 #elif defined(OS_POSIX)
844 {L"bad*file?name.jpg", L"bad-file-name.jpg"}, 843 {L"bad*file?name.jpg", L"bad-file-name.jpg"},
845 {L"\t bad*file?name/.jpg ", L"bad-file-name-.jpg"}, 844 {L"\t bad*file?name/.jpg ", L"bad-file-name-.jpg"},
846 {L"bad\uFFFFfile-name.jpg ", L"bad-file-name.jpg"},
847 #endif 845 #endif
848 {L"this_file_name is okay!.mp3", L"this_file_name is okay!.mp3"}, 846 {L"this_file_name is okay!.mp3", L"this_file_name is okay!.mp3"},
849 {L"\u4E00\uAC00.mp3", L"\u4E00\uAC00.mp3"}, 847 {L"\u4E00\uAC00.mp3", L"\u4E00\uAC00.mp3"},
850 {L"\u0635\u200C\u0644.mp3", L"\u0635\u200C\u0644.mp3"}, 848 {L"\u0635\u200C\u0644.mp3", L"\u0635\u200C\u0644.mp3"},
851 {L"\U00010330\U00010331.mp3", L"\U00010330\U00010331.mp3"}, 849 {L"\U00010330\U00010331.mp3", L"\U00010330\U00010331.mp3"},
852 // Unassigned codepoints are ok. 850 // Unassigned codepoints are ok.
853 {L"\u0378\U00040001.mp3", L"\u0378\U00040001.mp3"}, 851 {L"\u0378\U00040001.mp3", L"\u0378\U00040001.mp3"},
852 // Non-characters are not allowed.
853 {L"bad\uFFFFfile\U0010FFFEname.jpg ", L"bad-file-name.jpg"},
854 {L"bad\uFDD0file\uFDEFname.jpg ", L"bad-file-name.jpg"},
854 }; 855 };
855 856
856 TEST_F(FileUtilTest, ReplaceIllegalCharactersTest) { 857 TEST_F(FileUtilTest, ReplaceIllegalCharactersTest) {
857 for (unsigned int i = 0; i < arraysize(kIllegalCharacterCases); ++i) { 858 for (unsigned int i = 0; i < arraysize(kIllegalCharacterCases); ++i) {
858 std::wstring bad_name(kIllegalCharacterCases[i].bad_name); 859 std::wstring bad_name(kIllegalCharacterCases[i].bad_name);
859 file_util::ReplaceIllegalCharacters(&bad_name, L'-'); 860 file_util::ReplaceIllegalCharacters(&bad_name, L'-');
860 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name); 861 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name);
861 } 862 }
862 } 863 }
863 864
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 #elif defined(OS_LINUX) 1143 #elif defined(OS_LINUX)
1143 EXPECT_FALSE(file_util::ContainsPath(foo, 1144 EXPECT_FALSE(file_util::ContainsPath(foo,
1144 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); 1145 foo_caps.Append(FILE_PATH_LITERAL("bar.txt"))));
1145 #else 1146 #else
1146 // We can't really do this test on osx since the case-sensitivity of the 1147 // We can't really do this test on osx since the case-sensitivity of the
1147 // filesystem is configurable. 1148 // filesystem is configurable.
1148 #endif 1149 #endif
1149 } 1150 }
1150 1151
1151 } // namespace 1152 } // namespace
OLDNEW
« no previous file with comments | « no previous file | base/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698