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

Side by Side Diff: test/cctest/test-strings.cc

Issue 12700008: remove latin-1 flag (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: removed SeqOneByteStringVerify Created 7 years, 9 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 | « test/cctest/test-api.cc ('k') | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 } 1295 }
1296 1296
1297 1297
1298 TEST(IsAscii) { 1298 TEST(IsAscii) {
1299 CHECK(String::IsAscii(static_cast<char*>(NULL), 0)); 1299 CHECK(String::IsAscii(static_cast<char*>(NULL), 0));
1300 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0)); 1300 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0));
1301 } 1301 }
1302 1302
1303 1303
1304 1304
1305 #ifdef ENABLE_LATIN_1
1306 template<typename Op, bool return_first> 1305 template<typename Op, bool return_first>
1307 static uint16_t ConvertLatin1(uint16_t c) { 1306 static uint16_t ConvertLatin1(uint16_t c) {
1308 uint32_t result[Op::kMaxWidth]; 1307 uint32_t result[Op::kMaxWidth];
1309 int chars; 1308 int chars;
1310 chars = Op::Convert(c, 0, result, NULL); 1309 chars = Op::Convert(c, 0, result, NULL);
1311 if (chars == 0) return 0; 1310 if (chars == 0) return 0;
1312 CHECK_LE(chars, static_cast<int>(sizeof(result))); 1311 CHECK_LE(chars, static_cast<int>(sizeof(result)));
1313 if (!return_first && chars > 1) { 1312 if (!return_first && chars > 1) {
1314 return 0; 1313 return 0;
1315 } 1314 }
1316 return result[0]; 1315 return result[0];
1317 } 1316 }
1318 1317
1319 1318
1320 static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) { 1319 static void CheckCanonicalEquivalence(uint16_t c, uint16_t test) {
1321 uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c); 1320 uint16_t expect = ConvertLatin1<unibrow::Ecma262UnCanonicalize, true>(c);
1322 if (expect > unibrow::Latin1::kMaxChar) expect = 0; 1321 if (expect > unibrow::Latin1::kMaxChar) expect = 0;
1323 CHECK_EQ(expect, test); 1322 CHECK_EQ(expect, test);
1324 } 1323 }
1325 1324
1326 1325
1327 TEST(Latin1IgnoreCase) { 1326 TEST(Latin1IgnoreCase) {
1328 if (true) return;
1329 using namespace unibrow; 1327 using namespace unibrow;
1330 for (uint16_t c = Latin1::kMaxChar + 1; c != 0; c++) { 1328 for (uint16_t c = Latin1::kMaxChar + 1; c != 0; c++) {
1331 uint16_t lower = ConvertLatin1<ToLowercase, false>(c); 1329 uint16_t lower = ConvertLatin1<ToLowercase, false>(c);
1332 uint16_t upper = ConvertLatin1<ToUppercase, false>(c); 1330 uint16_t upper = ConvertLatin1<ToUppercase, false>(c);
1333 uint16_t test = Latin1::ConvertNonLatin1ToLatin1(c); 1331 uint16_t test = Latin1::ConvertNonLatin1ToLatin1(c);
1334 // Filter out all character whose upper is not their lower or vice versa. 1332 // Filter out all character whose upper is not their lower or vice versa.
1335 if (lower == 0 && upper == 0) { 1333 if (lower == 0 && upper == 0) {
1336 CheckCanonicalEquivalence(c, test); 1334 CheckCanonicalEquivalence(c, test);
1337 continue; 1335 continue;
1338 } 1336 }
(...skipping 11 matching lines...) Expand all
1350 CheckCanonicalEquivalence(c, test); 1348 CheckCanonicalEquivalence(c, test);
1351 continue; 1349 continue;
1352 } 1350 }
1353 if (upper != c && lower != c) { 1351 if (upper != c && lower != c) {
1354 CheckCanonicalEquivalence(c, test); 1352 CheckCanonicalEquivalence(c, test);
1355 continue; 1353 continue;
1356 } 1354 }
1357 CHECK_EQ(Min(upper, lower), test); 1355 CHECK_EQ(Min(upper, lower), test);
1358 } 1356 }
1359 } 1357 }
1360 #endif // ENABLE_LATIN_1
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698