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

Side by Side Diff: base/sys_string_conversions_unittest.cc

Issue 147146: Only run the UTF-8 assuming sys conversion tests on Linux. (Closed)
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
« no previous file with comments | « no previous file | 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) 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 "base/basictypes.h"
5 #include "base/string_piece.h" 6 #include "base/string_piece.h"
6 #include "base/string_util.h" 7 #include "base/string_util.h"
7 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 #ifdef WCHAR_T_IS_UTF32 11 #ifdef WCHAR_T_IS_UTF32
11 static const std::wstring kSysWideOldItalicLetterA = L"\x10300"; 12 static const std::wstring kSysWideOldItalicLetterA = L"\x10300";
12 #else 13 #else
13 static const std::wstring kSysWideOldItalicLetterA = L"\xd800\xdf00"; 14 static const std::wstring kSysWideOldItalicLetterA = L"\xd800\xdf00";
14 #endif 15 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 utf8_null.push_back('b'); 63 utf8_null.push_back('b');
63 64
64 std::wstring expected_null(L"a"); 65 std::wstring expected_null(L"a");
65 expected_null.push_back(0); 66 expected_null.push_back(0);
66 expected_null.push_back('b'); 67 expected_null.push_back('b');
67 68
68 EXPECT_EQ(expected_null, SysUTF8ToWide(utf8_null)); 69 EXPECT_EQ(expected_null, SysUTF8ToWide(utf8_null));
69 } 70 }
70 71
71 // We assume the test is running in a UTF8 locale. 72 // We assume the test is running in a UTF8 locale.
73 #if defined(OS_LINUX)
72 TEST(SysStrings, SysWideToNativeMB) { 74 TEST(SysStrings, SysWideToNativeMB) {
73 using base::SysWideToNativeMB; 75 using base::SysWideToNativeMB;
74 EXPECT_EQ("Hello, world", SysWideToNativeMB(L"Hello, world")); 76 EXPECT_EQ("Hello, world", SysWideToNativeMB(L"Hello, world"));
75 EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToNativeMB(L"\x4f60\x597d")); 77 EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToNativeMB(L"\x4f60\x597d"));
76 78
77 // >16 bits 79 // >16 bits
78 EXPECT_EQ("\xF0\x90\x8C\x80", SysWideToNativeMB(kSysWideOldItalicLetterA)); 80 EXPECT_EQ("\xF0\x90\x8C\x80", SysWideToNativeMB(kSysWideOldItalicLetterA));
79 81
80 // Error case. When Windows finds a UTF-16 character going off the end of 82 // Error case. When Windows finds a UTF-16 character going off the end of
81 // a string, it just converts that literal value to UTF-8, even though this 83 // a string, it just converts that literal value to UTF-8, even though this
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 EXPECT_EQ(wide, trip); 171 EXPECT_EQ(wide, trip);
170 } 172 }
171 173
172 for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { 174 for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) {
173 std::wstring wide = kConvertRoundtripCases[i]; 175 std::wstring wide = kConvertRoundtripCases[i];
174 std::wstring trip = UTF8ToWide(base::SysWideToNativeMB(wide)); 176 std::wstring trip = UTF8ToWide(base::SysWideToNativeMB(wide));
175 EXPECT_EQ(wide.size(), trip.size()); 177 EXPECT_EQ(wide.size(), trip.size());
176 EXPECT_EQ(wide, trip); 178 EXPECT_EQ(wide, trip);
177 } 179 }
178 } 180 }
181 #endif // OS_LINUX
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698