OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 } | 1185 } |
1186 | 1186 |
1187 | 1187 |
1188 TEST_CASE(StringSubStringDifferentWidth) { | 1188 TEST_CASE(StringSubStringDifferentWidth) { |
1189 // Create 1-byte substring from a 1-byte source string. | 1189 // Create 1-byte substring from a 1-byte source string. |
1190 const char* onechars = | 1190 const char* onechars = |
1191 "\xC3\xB6\xC3\xB1\xC3\xA9"; | 1191 "\xC3\xB6\xC3\xB1\xC3\xA9"; |
1192 | 1192 |
1193 const String& onestr = String::Handle(String::New(onechars)); | 1193 const String& onestr = String::Handle(String::New(onechars)); |
1194 EXPECT(!onestr.IsNull()); | 1194 EXPECT(!onestr.IsNull()); |
1195 EXPECT(!onestr.IsOneByteString()); | 1195 EXPECT(onestr.IsOneByteString()); |
1196 EXPECT(onestr.IsTwoByteString()); | 1196 EXPECT(!onestr.IsTwoByteString()); |
1197 | 1197 |
1198 const String& onesub = String::Handle(String::SubString(onestr, 0)); | 1198 const String& onesub = String::Handle(String::SubString(onestr, 0)); |
1199 EXPECT(!onesub.IsNull()); | 1199 EXPECT(!onesub.IsNull()); |
1200 EXPECT(!onestr.IsOneByteString()); | 1200 EXPECT(onestr.IsOneByteString()); |
1201 EXPECT(onestr.IsTwoByteString()); | 1201 EXPECT(!onestr.IsTwoByteString()); |
1202 EXPECT_EQ(onesub.Length(), 3); | 1202 EXPECT_EQ(onesub.Length(), 3); |
1203 | 1203 |
1204 // Create 1- and 2-byte substrings from a 2-byte source string. | 1204 // Create 1- and 2-byte substrings from a 2-byte source string. |
1205 const char* twochars = | 1205 const char* twochars = |
1206 "\x1f\x2f\x3f" | 1206 "\x1f\x2f\x3f" |
1207 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93"; | 1207 "\xE1\xB9\xAB\xE1\xBA\x85\xE1\xB9\x93"; |
1208 | 1208 |
1209 const String& twostr = String::Handle(String::New(twochars)); | 1209 const String& twostr = String::Handle(String::New(twochars)); |
1210 EXPECT(!twostr.IsNull()); | 1210 EXPECT(!twostr.IsNull()); |
1211 EXPECT(twostr.IsTwoByteString()); | 1211 EXPECT(twostr.IsTwoByteString()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, | 1283 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, |
1284 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, | 1284 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, |
1285 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, | 1285 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, |
1286 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, | 1286 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, |
1287 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, | 1287 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, |
1288 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, | 1288 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, |
1289 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, | 1289 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, |
1290 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, | 1290 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, |
1291 }; | 1291 }; |
1292 const String& str = String::Handle(String::New(src)); | 1292 const String& str = String::Handle(String::New(src)); |
1293 EXPECT(str.IsTwoByteString()); | 1293 EXPECT(str.IsOneByteString()); |
1294 intptr_t expected_length = sizeof(expected); | 1294 intptr_t expected_length = sizeof(expected); |
1295 EXPECT_EQ(expected_length, str.Length()); | 1295 EXPECT_EQ(expected_length, str.Length()); |
1296 for (int i = 0; i < str.Length(); ++i) { | 1296 for (int i = 0; i < str.Length(); ++i) { |
1297 EXPECT_EQ(expected[i], str.CharAt(i)); | 1297 EXPECT_EQ(expected[i], str.CharAt(i)); |
1298 } | 1298 } |
1299 } | 1299 } |
1300 | 1300 |
1301 // Create a 2-byte string from a UTF-8 encoded string literal. | 1301 // Create a 2-byte string from a UTF-8 encoded string literal. |
1302 { | 1302 { |
1303 const char* src = | 1303 const char* src = |
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); | 3248 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); |
3249 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); | 3249 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); |
3250 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); | 3250 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); |
3251 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); | 3251 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); |
3252 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); | 3252 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); |
3253 } | 3253 } |
3254 | 3254 |
3255 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3255 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
3256 | 3256 |
3257 } // namespace dart | 3257 } // namespace dart |
OLD | NEW |