OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 | 2 |
3 // Check that we can traverse very deep stacks of ConsStrings using | 3 // Check that we can traverse very deep stacks of ConsStrings using |
4 // StringCharacterStram. Check that Get(int) works on very deep stacks | 4 // StringCharacterStram. Check that Get(int) works on very deep stacks |
5 // of ConsStrings. These operations may not be very fast, but they | 5 // of ConsStrings. These operations may not be very fast, but they |
6 // should be possible without getting errors due to too deep recursion. | 6 // should be possible without getting errors due to too deep recursion. |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "v8.h" | 10 #include "v8.h" |
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1268 |
1269 v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80"); | 1269 v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80"); |
1270 CHECK(expected->Equals(result)); | 1270 CHECK(expected->Equals(result)); |
1271 } | 1271 } |
1272 | 1272 |
1273 | 1273 |
1274 TEST(IsAscii) { | 1274 TEST(IsAscii) { |
1275 CHECK(String::IsAscii(static_cast<char*>(NULL), 0)); | 1275 CHECK(String::IsAscii(static_cast<char*>(NULL), 0)); |
1276 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0)); | 1276 CHECK(String::IsOneByte(static_cast<uc16*>(NULL), 0)); |
1277 } | 1277 } |
| 1278 |
| 1279 |
| 1280 static bool CanBeConvertedToLatin1(uint16_t c) { |
| 1281 CHECK(c > unibrow::Latin1::kMaxChar); |
| 1282 uint32_t result[4]; |
| 1283 int chars; |
| 1284 chars = unibrow::ToLowercase::Convert(c, 0, result, NULL); |
| 1285 if (chars > 0) { |
| 1286 CHECK_LE(chars, static_cast<int>(sizeof(result))); |
| 1287 for (int i = 0; i < chars; i++ ) { |
| 1288 if (result[i] <= unibrow::Latin1::kMaxChar) { |
| 1289 return true; |
| 1290 } |
| 1291 } |
| 1292 } |
| 1293 chars = unibrow::ToUppercase::Convert(c, 0, result, NULL); |
| 1294 if (chars > 0) { |
| 1295 CHECK_LE(chars, static_cast<int>(sizeof(result))); |
| 1296 for (int i = 0; i < chars; i++ ) { |
| 1297 if (result[i] <= unibrow::Latin1::kMaxChar) { |
| 1298 return true; |
| 1299 } |
| 1300 } |
| 1301 } |
| 1302 return false; |
| 1303 } |
| 1304 |
| 1305 |
| 1306 TEST(Latin1) { |
| 1307 #ifndef ENABLE_LATIN_1 |
| 1308 if (true) return; |
| 1309 #endif |
| 1310 for (uint16_t c = unibrow::Latin1::kMaxChar + 1; c != 0; c++) { |
| 1311 CHECK_EQ(CanBeConvertedToLatin1(c), |
| 1312 unibrow::Latin1::NonLatin1CanBeConvertedToLatin1(c)); |
| 1313 } |
| 1314 } |
OLD | NEW |