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

Side by Side Diff: base/string_util_unittest.cc

Issue 552026: Revert 36459 - Breaks 7 WebKit tests... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 11 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/string_util.cc ('k') | base/utf_string_conversion_utils.h » ('j') | 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) 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 <math.h> 5 #include <math.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // BOMs in UTF-16(BE|LE) and UTF-32(BE|LE) 218 // BOMs in UTF-16(BE|LE) and UTF-32(BE|LE)
219 EXPECT_FALSE(IsStringUTF8("\xfe\xff")); 219 EXPECT_FALSE(IsStringUTF8("\xfe\xff"));
220 EXPECT_FALSE(IsStringUTF8("\xff\xfe")); 220 EXPECT_FALSE(IsStringUTF8("\xff\xfe"));
221 EXPECT_FALSE(IsStringUTF8(std::string("\x00\x00\xfe\xff", 4))); 221 EXPECT_FALSE(IsStringUTF8(std::string("\x00\x00\xfe\xff", 4)));
222 EXPECT_FALSE(IsStringUTF8("\xff\xfe\x00\x00")); 222 EXPECT_FALSE(IsStringUTF8("\xff\xfe\x00\x00"));
223 223
224 // Non-characters : U+xxFFF[EF] where xx is 0x00 through 0x10 and <FDD0,FDEF> 224 // Non-characters : U+xxFFF[EF] where xx is 0x00 through 0x10 and <FDD0,FDEF>
225 EXPECT_FALSE(IsStringUTF8("\xef\xbf\xbe")); // U+FFFE) 225 EXPECT_FALSE(IsStringUTF8("\xef\xbf\xbe")); // U+FFFE)
226 EXPECT_FALSE(IsStringUTF8("\xf0\x8f\xbf\xbe")); // U+1FFFE 226 EXPECT_FALSE(IsStringUTF8("\xf0\x8f\xbf\xbe")); // U+1FFFE
227 EXPECT_FALSE(IsStringUTF8("\xf3\xbf\xbf\xbf")); // U+10FFFF 227 EXPECT_FALSE(IsStringUTF8("\xf3\xbf\xbf\xbf")); // U+10FFFF
228
229 // This should also be false, but currently we pass them through.
230 // Disable them for now.
231 #if 0
228 EXPECT_FALSE(IsStringUTF8("\xef\xb7\x90")); // U+FDD0 232 EXPECT_FALSE(IsStringUTF8("\xef\xb7\x90")); // U+FDD0
229 EXPECT_FALSE(IsStringUTF8("\xef\xb7\xaf")); // U+FDEF 233 EXPECT_FALSE(IsStringUTF8("\xef\xb7\xaf")); // U+FDEF
234 #endif
230 235
231 // Strings in legacy encodings. We can certainly make up strings 236 // Strings in legacy encodings. We can certainly make up strings
232 // in a legacy encoding that are valid in UTF-8, but in real data, 237 // in a legacy encoding that are valid in UTF-8, but in real data,
233 // most of them are invalid as UTF-8. 238 // most of them are invalid as UTF-8.
234 EXPECT_FALSE(IsStringUTF8("caf\xe9")); // cafe with U+00E9 in ISO-8859-1 239 EXPECT_FALSE(IsStringUTF8("caf\xe9")); // cafe with U+00E9 in ISO-8859-1
235 EXPECT_FALSE(IsStringUTF8("\xb0\xa1\xb0\xa2")); // U+AC00, U+AC001 in EUC-KR 240 EXPECT_FALSE(IsStringUTF8("\xb0\xa1\xb0\xa2")); // U+AC00, U+AC001 in EUC-KR
236 EXPECT_FALSE(IsStringUTF8("\xa7\x41\xa6\x6e")); // U+4F60 U+597D in Big5 241 EXPECT_FALSE(IsStringUTF8("\xa7\x41\xa6\x6e")); // U+4F60 U+597D in Big5
237 // "abc" with U+201[CD] in windows-125[0-8] 242 // "abc" with U+201[CD] in windows-125[0-8]
238 EXPECT_FALSE(IsStringUTF8("\x93" "abc\x94")); 243 EXPECT_FALSE(IsStringUTF8("\x93" "abc\x94"));
239 // U+0639 U+064E U+0644 U+064E in ISO-8859-6 244 // U+0639 U+064E U+0644 U+064E in ISO-8859-6
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 1462
1458 TEST(StringUtilTest, HexEncode) { 1463 TEST(StringUtilTest, HexEncode) {
1459 std::string hex(HexEncode(NULL, 0)); 1464 std::string hex(HexEncode(NULL, 0));
1460 EXPECT_EQ(hex.length(), 0U); 1465 EXPECT_EQ(hex.length(), 0U);
1461 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; 1466 unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81};
1462 hex = HexEncode(bytes, sizeof(bytes)); 1467 hex = HexEncode(bytes, sizeof(bytes));
1463 EXPECT_EQ(hex.compare("01FF02FE038081"), 0); 1468 EXPECT_EQ(hex.compare("01FF02FE038081"), 0);
1464 } 1469 }
1465 1470
1466 } // namaspace base 1471 } // namaspace base
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | base/utf_string_conversion_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698