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

Side by Side Diff: base/i18n/file_util_icu_unittest.cc

Issue 267001: Separate out some more ICU from base and into base/i18n.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « base/i18n/file_util_icu.cc ('k') | base/i18n/number_formatting.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/i18n/file_util_icu.h"
6
7 #include "base/file_util.h"
8 #include "base/path_service.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h"
11
12 // file_util winds up using autoreleased objects on the Mac, so this needs
13 // to be a PlatformTest
14 class FileUtilICUTest : public PlatformTest {
15 protected:
16 virtual void SetUp() {
17 PlatformTest::SetUp();
18 // Name a subdirectory of the temp directory.
19 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_));
20 test_dir_ = test_dir_.Append(FILE_PATH_LITERAL("FileUtilTest"));
21
22 // Create a fresh, empty copy of this directory.
23 file_util::Delete(test_dir_, true);
24 file_util::CreateDirectory(test_dir_);
25 }
26 virtual void TearDown() {
27 PlatformTest::TearDown();
28 // Clean up test directory
29 ASSERT_TRUE(file_util::Delete(test_dir_, true));
30 ASSERT_FALSE(file_util::PathExists(test_dir_));
31 }
32
33 // the path to temporary directory used to contain the test operations
34 FilePath test_dir_;
35 };
36
37 static const struct goodbad_pair {
38 std::wstring bad_name;
39 std::wstring good_name;
40 } kIllegalCharacterCases[] = {
41 {L"bad*file:name?.jpg", L"bad-file-name-.jpg"},
42 {L"**********::::.txt", L"--------------.txt"},
43 // We can't use UCNs (universal character names) for C0/C1 characters and
44 // U+007F, but \x escape is interpreted by MSVC and gcc as we intend.
45 {L"bad\x0003\x0091 file\u200E\u200Fname.png", L"bad-- file--name.png"},
46 #if defined(OS_WIN)
47 {L"bad*file\\name.jpg", L"bad-file-name.jpg"},
48 {L"\t bad*file\\name/.jpg ", L"bad-file-name-.jpg"},
49 #elif defined(OS_POSIX)
50 {L"bad*file?name.jpg", L"bad-file-name.jpg"},
51 {L"\t bad*file?name/.jpg ", L"bad-file-name-.jpg"},
52 #endif
53 {L"this_file_name is okay!.mp3", L"this_file_name is okay!.mp3"},
54 {L"\u4E00\uAC00.mp3", L"\u4E00\uAC00.mp3"},
55 {L"\u0635\u200C\u0644.mp3", L"\u0635\u200C\u0644.mp3"},
56 {L"\U00010330\U00010331.mp3", L"\U00010330\U00010331.mp3"},
57 // Unassigned codepoints are ok.
58 {L"\u0378\U00040001.mp3", L"\u0378\U00040001.mp3"},
59 // Non-characters are not allowed.
60 {L"bad\uFFFFfile\U0010FFFEname.jpg ", L"bad-file-name.jpg"},
61 {L"bad\uFDD0file\uFDEFname.jpg ", L"bad-file-name.jpg"},
62 };
63
64 TEST_F(FileUtilICUTest, ReplaceIllegalCharactersTest) {
65 for (unsigned int i = 0; i < arraysize(kIllegalCharacterCases); ++i) {
66 std::wstring bad_name(kIllegalCharacterCases[i].bad_name);
67 file_util::ReplaceIllegalCharacters(&bad_name, L'-');
68 EXPECT_EQ(kIllegalCharacterCases[i].good_name, bad_name);
69 }
70 }
71
OLDNEW
« no previous file with comments | « base/i18n/file_util_icu.cc ('k') | base/i18n/number_formatting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698