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

Side by Side Diff: base/string16_unittest.cc

Issue 243102: Convert base dependencies to use sys_string_conversions instead of the ICU... (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/string16.cc ('k') | 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')
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 <sstream>
6
7 #include "base/string16.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 #if defined(WCHAR_T_IS_UTF32)
11
12 // We define a custom operator<< for string16 so we can use it with logging.
13 // This tests that conversion.
14 TEST(String16Test, OutputStream) {
15 // Basic stream test.
16 {
17 std::ostringstream stream;
18 stream << "Empty '" << string16() << "' standard '"
19 << string16(ASCIIToUTF16("Hello, world")) << "'";
20 EXPECT_STREQ("Empty '' standard 'Hello, world'",
21 stream.str().c_str());
22 }
23
24 // Interesting edge cases.
25 {
26 // These should each get converted to the invalid character: EF BF BD.
27 string16 initial_surrogate;
28 initial_surrogate.push_back(0xd800);
29 string16 final_surrogate;
30 final_surrogate.push_back(0xdc00);
31
32 // Old italic A = U+10300, will get converted to: F0 90 8C 80 'z'.
33 string16 surrogate_pair;
34 surrogate_pair.push_back(0xd800);
35 surrogate_pair.push_back(0xdf00);
36 surrogate_pair.push_back('z');
37
38 // Will get converted to the invalid char + 's': EF BF BD 's'.
39 string16 unterminated_surrogate;
40 unterminated_surrogate.push_back(0xd800);
41 unterminated_surrogate.push_back('s');
42
43 std::ostringstream stream;
44 stream << initial_surrogate << "," << final_surrogate << ","
45 << surrogate_pair << ",", unterminated_surrogate;
46
47 EXPECT_STREQ("\xef\xbf\xbd,\xef\xbf\xbd,\xf0\x90\x8c\x80z,\xef\xbf\xbds",
48 stream.str().c_str());
49 }
50 }
51
52 #endif
OLDNEW
« no previous file with comments | « base/string16.cc ('k') | base/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698