OLD | NEW |
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 18240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18251 TEST(ContainsOnlyOneByte) { | 18251 TEST(ContainsOnlyOneByte) { |
18252 v8::V8::Initialize(); | 18252 v8::V8::Initialize(); |
18253 v8::Isolate* isolate = CcTest::isolate(); | 18253 v8::Isolate* isolate = CcTest::isolate(); |
18254 v8::HandleScope scope(isolate); | 18254 v8::HandleScope scope(isolate); |
18255 // Make a buffer long enough that it won't automatically be converted. | 18255 // Make a buffer long enough that it won't automatically be converted. |
18256 const int length = 512; | 18256 const int length = 512; |
18257 // Ensure word aligned assignment. | 18257 // Ensure word aligned assignment. |
18258 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); | 18258 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); |
18259 i::SmartArrayPointer<uintptr_t> | 18259 i::SmartArrayPointer<uintptr_t> |
18260 aligned_contents(new uintptr_t[aligned_length]); | 18260 aligned_contents(new uintptr_t[aligned_length]); |
18261 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); | 18261 uint16_t* string_contents = |
| 18262 reinterpret_cast<uint16_t*>(aligned_contents.get()); |
18262 // Set to contain only one byte. | 18263 // Set to contain only one byte. |
18263 for (int i = 0; i < length-1; i++) { | 18264 for (int i = 0; i < length-1; i++) { |
18264 string_contents[i] = 0x41; | 18265 string_contents[i] = 0x41; |
18265 } | 18266 } |
18266 string_contents[length-1] = 0; | 18267 string_contents[length-1] = 0; |
18267 // Simple case. | 18268 // Simple case. |
18268 Handle<String> string; | 18269 Handle<String> string; |
18269 string = String::NewExternal(isolate, new TestResource(string_contents)); | 18270 string = String::NewExternal(isolate, new TestResource(string_contents)); |
18270 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); | 18271 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); |
18271 // Counter example. | 18272 // Counter example. |
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20854 } | 20855 } |
20855 for (int i = 0; i < runs; i++) { | 20856 for (int i = 0; i < runs; i++) { |
20856 Local<String> expected; | 20857 Local<String> expected; |
20857 if (i != 0) { | 20858 if (i != 0) { |
20858 CHECK_EQ(v8_str("escape value"), values[i]); | 20859 CHECK_EQ(v8_str("escape value"), values[i]); |
20859 } else { | 20860 } else { |
20860 CHECK(values[i].IsEmpty()); | 20861 CHECK(values[i].IsEmpty()); |
20861 } | 20862 } |
20862 } | 20863 } |
20863 } | 20864 } |
OLD | NEW |