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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "platform/json.h" | 7 #include "platform/json.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 EXPECT_VALID(result); | 506 EXPECT_VALID(result); |
507 int64_t value; | 507 int64_t value; |
508 result = Dart_IntegerToInt64(result, &value); | 508 result = Dart_IntegerToInt64(result, &value); |
509 EXPECT_VALID(result); | 509 EXPECT_VALID(result); |
510 EXPECT_EQ(i, value); | 510 EXPECT_EQ(i, value); |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 | 514 |
515 TEST_CASE(IsString) { | 515 TEST_CASE(IsString) { |
| 516 uint8_t latin1[] = { 'o', 'n', 'e', 0xC2, 0xA2 }; |
| 517 |
| 518 Dart_Handle latin1str = Dart_NewStringFromUTF8(latin1, ARRAY_SIZE(latin1)); |
| 519 EXPECT_VALID(latin1str); |
| 520 EXPECT(Dart_IsString(latin1str)); |
| 521 EXPECT(Dart_IsStringLatin1(latin1str)); |
| 522 EXPECT(!Dart_IsExternalString(latin1str)); |
| 523 intptr_t len = -1; |
| 524 EXPECT_VALID(Dart_StringLength(latin1str, &len)); |
| 525 EXPECT_EQ(4, len); |
| 526 |
516 uint8_t data8[] = { 'o', 'n', 'e', 0x7F }; | 527 uint8_t data8[] = { 'o', 'n', 'e', 0x7F }; |
517 | 528 |
518 Dart_Handle str8 = Dart_NewStringFromUTF8(data8, ARRAY_SIZE(data8)); | 529 Dart_Handle str8 = Dart_NewStringFromUTF8(data8, ARRAY_SIZE(data8)); |
519 EXPECT_VALID(str8); | 530 EXPECT_VALID(str8); |
520 EXPECT(Dart_IsString(str8)); | 531 EXPECT(Dart_IsString(str8)); |
521 EXPECT(Dart_IsStringLatin1(str8)); | 532 EXPECT(Dart_IsStringLatin1(str8)); |
522 EXPECT(!Dart_IsExternalString(str8)); | 533 EXPECT(!Dart_IsExternalString(str8)); |
523 | 534 |
524 Dart_Handle ext8 = Dart_NewExternalLatin1String(data8, ARRAY_SIZE(data8), | 535 Dart_Handle ext8 = Dart_NewExternalLatin1String(data8, ARRAY_SIZE(data8), |
525 NULL, NULL); | 536 NULL, NULL); |
(...skipping 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7338 Dart_LoadSource(TestCase::lib(), url, source); | 7349 Dart_LoadSource(TestCase::lib(), url, source); |
7339 | 7350 |
7340 dart_args[0] = Dart_NewInteger(1); | 7351 dart_args[0] = Dart_NewInteger(1); |
7341 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args); | 7352 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args); |
7342 EXPECT_VALID(result); | 7353 EXPECT_VALID(result); |
7343 } | 7354 } |
7344 | 7355 |
7345 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7356 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
7346 | 7357 |
7347 } // namespace dart | 7358 } // namespace dart |
OLD | NEW |