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

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

Issue 1273243002: Updates to base unittests so they run correctly in libchrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Existing tests using ScopedLocale are wrapped by OS_LINUX, trying that Created 5 years, 4 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
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 <sstream> 5 #include <sstream>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 #if defined(OS_POSIX)
14 #include "base/test/scoped_locale.h"
15 #endif
16
13 // This macro helps avoid wrapped lines in the test structs. 17 // This macro helps avoid wrapped lines in the test structs.
14 #define FPL(x) FILE_PATH_LITERAL(x) 18 #define FPL(x) FILE_PATH_LITERAL(x)
15 19
16 // This macro constructs strings which can contain NULs. 20 // This macro constructs strings which can contain NULs.
17 #define FPS(x) FilePath::StringType(FPL(x), arraysize(FPL(x)) - 1) 21 #define FPS(x) FilePath::StringType(FPL(x), arraysize(FPL(x)) - 1)
18 22
19 namespace base { 23 namespace base {
20 24
21 struct UnaryTestData { 25 struct UnaryTestData {
22 const FilePath::CharType* input; 26 const FilePath::CharType* input;
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 TEST_F(FilePathTest, FromUTF8Unsafe_And_AsUTF8Unsafe) { 1123 TEST_F(FilePathTest, FromUTF8Unsafe_And_AsUTF8Unsafe) {
1120 const struct UTF8TestData cases[] = { 1124 const struct UTF8TestData cases[] = {
1121 { FPL("foo.txt"), "foo.txt" }, 1125 { FPL("foo.txt"), "foo.txt" },
1122 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. 1126 // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them.
1123 { FPL("\u00E0\u00E8\u00F2.txt"), "\xC3\xA0\xC3\xA8\xC3\xB2.txt" }, 1127 { FPL("\u00E0\u00E8\u00F2.txt"), "\xC3\xA0\xC3\xA8\xC3\xB2.txt" },
1124 // Full-width "ABC". 1128 // Full-width "ABC".
1125 { FPL("\uFF21\uFF22\uFF23.txt"), 1129 { FPL("\uFF21\uFF22\uFF23.txt"),
1126 "\xEF\xBC\xA1\xEF\xBC\xA2\xEF\xBC\xA3.txt" }, 1130 "\xEF\xBC\xA1\xEF\xBC\xA2\xEF\xBC\xA3.txt" },
1127 }; 1131 };
1128 1132
1133 #if !defined(SYSTEM_NATIVE_UTF8) && defined(OS_LINUX)
1134 ScopedLocale locale("en_US.UTF-8");
1135 #endif
1136
1129 for (size_t i = 0; i < arraysize(cases); ++i) { 1137 for (size_t i = 0; i < arraysize(cases); ++i) {
1130 // Test FromUTF8Unsafe() works. 1138 // Test FromUTF8Unsafe() works.
1131 FilePath from_utf8 = FilePath::FromUTF8Unsafe(cases[i].utf8); 1139 FilePath from_utf8 = FilePath::FromUTF8Unsafe(cases[i].utf8);
1132 EXPECT_EQ(cases[i].native, from_utf8.value()) 1140 EXPECT_EQ(cases[i].native, from_utf8.value())
1133 << "i: " << i << ", input: " << cases[i].native; 1141 << "i: " << i << ", input: " << cases[i].native;
1134 // Test AsUTF8Unsafe() works. 1142 // Test AsUTF8Unsafe() works.
1135 FilePath from_native = FilePath(cases[i].native); 1143 FilePath from_native = FilePath(cases[i].native);
1136 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe()) 1144 EXPECT_EQ(cases[i].utf8, from_native.AsUTF8Unsafe())
1137 << "i: " << i << ", input: " << cases[i].native; 1145 << "i: " << i << ", input: " << cases[i].native;
1138 // Test the two file paths are identical. 1146 // Test the two file paths are identical.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // Test the PrintTo overload for FilePath (used when a test fails to compare two 1286 // Test the PrintTo overload for FilePath (used when a test fails to compare two
1279 // FilePaths). 1287 // FilePaths).
1280 TEST_F(FilePathTest, PrintTo) { 1288 TEST_F(FilePathTest, PrintTo) {
1281 std::stringstream ss; 1289 std::stringstream ss;
1282 FilePath fp(FPL("foo")); 1290 FilePath fp(FPL("foo"));
1283 base::PrintTo(fp, &ss); 1291 base::PrintTo(fp, &ss);
1284 EXPECT_EQ("foo", ss.str()); 1292 EXPECT_EQ("foo", ss.str());
1285 } 1293 }
1286 1294
1287 } // namespace base 1295 } // namespace base
OLDNEW
« no previous file with comments | « base/files/dir_reader_posix_unittest.cc ('k') | base/strings/sys_string_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698