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

Side by Side Diff: base/strings/utf_string_conversions_unittest.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/string_piece.h" 7 #include "base/strings/string_piece.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.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"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 WideToUTF8(convert_cases[i].utf32, 178 WideToUTF8(convert_cases[i].utf32,
179 wcslen(convert_cases[i].utf32), 179 wcslen(convert_cases[i].utf32),
180 &converted)); 180 &converted));
181 std::string expected(convert_cases[i].utf8); 181 std::string expected(convert_cases[i].utf8);
182 EXPECT_EQ(expected, converted); 182 EXPECT_EQ(expected, converted);
183 } 183 }
184 } 184 }
185 #endif // defined(WCHAR_T_IS_UTF32) 185 #endif // defined(WCHAR_T_IS_UTF32)
186 186
187 TEST(UTFStringConversionsTest, ConvertMultiString) { 187 TEST(UTFStringConversionsTest, ConvertMultiString) {
188 static wchar_t wmulti[] = { 188 static char16 multi16[] = {'f', 'o', 'o', '\0', 'b', 'a', 'r',
189 L'f', L'o', L'o', L'\0', 189 '\0', 'b', 'a', 'z', '\0', '\0'};
190 L'b', L'a', L'r', L'\0',
191 L'b', L'a', L'z', L'\0',
192 L'\0'
193 };
194 static char multi[] = { 190 static char multi[] = {
195 'f', 'o', 'o', '\0', 191 'f', 'o', 'o', '\0',
196 'b', 'a', 'r', '\0', 192 'b', 'a', 'r', '\0',
197 'b', 'a', 'z', '\0', 193 'b', 'a', 'z', '\0',
198 '\0' 194 '\0'
199 }; 195 };
200 std::wstring wmultistring; 196 string16 multistring16;
201 memcpy(WriteInto(&wmultistring, arraysize(wmulti)), wmulti, sizeof(wmulti)); 197 memcpy(WriteInto(&multistring16, arraysize(multi16)), multi16,
202 EXPECT_EQ(arraysize(wmulti) - 1, wmultistring.length()); 198 sizeof(multi16));
199 EXPECT_EQ(arraysize(multi16) - 1, multistring16.length());
203 std::string expected; 200 std::string expected;
204 memcpy(WriteInto(&expected, arraysize(multi)), multi, sizeof(multi)); 201 memcpy(WriteInto(&expected, arraysize(multi)), multi, sizeof(multi));
205 EXPECT_EQ(arraysize(multi) - 1, expected.length()); 202 EXPECT_EQ(arraysize(multi) - 1, expected.length());
206 const std::string& converted = WideToUTF8(wmultistring); 203 const std::string& converted = UTF16ToUTF8(multistring16);
207 EXPECT_EQ(arraysize(multi) - 1, converted.length()); 204 EXPECT_EQ(arraysize(multi) - 1, converted.length());
208 EXPECT_EQ(expected, converted); 205 EXPECT_EQ(expected, converted);
209 } 206 }
210 207
211 } // namespace base 208 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698