| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // StringInputBuffer. Check that Get(int) works on very deep stacks | 4 // StringInputBuffer. 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 DeleteArray<char>(foo); | 285 DeleteArray<char>(foo); |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 TEST(Utf8Conversion) { | 289 TEST(Utf8Conversion) { |
| 290 // Smoke test for converting strings to utf-8. | 290 // Smoke test for converting strings to utf-8. |
| 291 InitializeVM(); | 291 InitializeVM(); |
| 292 v8::HandleScope handle_scope; | 292 v8::HandleScope handle_scope; |
| 293 // A simple ascii string | 293 // A simple ascii string |
| 294 const char* ascii_string = "abcdef12345"; | 294 const char* ascii_string = "abcdef12345"; |
| 295 int len = v8::String::New(ascii_string, strlen(ascii_string))->Utf8Length(); | 295 int len = |
| 296 CHECK_EQ(strlen(ascii_string), len); | 296 v8::String::New(ascii_string, |
| 297 StrLength(ascii_string))->Utf8Length(); |
| 298 CHECK_EQ(StrLength(ascii_string), len); |
| 297 // A mixed ascii and non-ascii string | 299 // A mixed ascii and non-ascii string |
| 298 // U+02E4 -> CB A4 | 300 // U+02E4 -> CB A4 |
| 299 // U+0064 -> 64 | 301 // U+0064 -> 64 |
| 300 // U+12E4 -> E1 8B A4 | 302 // U+12E4 -> E1 8B A4 |
| 301 // U+0030 -> 30 | 303 // U+0030 -> 30 |
| 302 // U+3045 -> E3 81 85 | 304 // U+3045 -> E3 81 85 |
| 303 const uint16_t mixed_string[] = {0x02E4, 0x0064, 0x12E4, 0x0030, 0x3045}; | 305 const uint16_t mixed_string[] = {0x02E4, 0x0064, 0x12E4, 0x0030, 0x3045}; |
| 304 // The characters we expect to be output | 306 // The characters we expect to be output |
| 305 const unsigned char as_utf8[11] = {0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, | 307 const unsigned char as_utf8[11] = {0xCB, 0xA4, 0x64, 0xE1, 0x8B, 0xA4, 0x30, |
| 306 0xE3, 0x81, 0x85, 0x00}; | 308 0xE3, 0x81, 0x85, 0x00}; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 344 } |
| 343 | 345 |
| 344 const uint16_t* data() const { return data_; } | 346 const uint16_t* data() const { return data_; } |
| 345 size_t length() const { return length_; } | 347 size_t length() const { return length_; } |
| 346 | 348 |
| 347 private: | 349 private: |
| 348 const uint16_t* data_; | 350 const uint16_t* data_; |
| 349 size_t length_; | 351 size_t length_; |
| 350 bool* destructed_; | 352 bool* destructed_; |
| 351 }; | 353 }; |
| OLD | NEW |