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/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 EXPECT(!str16.IsOneByteString()); | 596 EXPECT(!str16.IsOneByteString()); |
597 EXPECT(str16.IsTwoByteString()); | 597 EXPECT(str16.IsTwoByteString()); |
598 EXPECT(!str16.IsFourByteString()); | 598 EXPECT(!str16.IsFourByteString()); |
599 EXPECT_EQ(0x0000, str16.CharAt(0)); | 599 EXPECT_EQ(0x0000, str16.CharAt(0)); |
600 EXPECT_EQ(0x7FFF, str16.CharAt(1)); | 600 EXPECT_EQ(0x7FFF, str16.CharAt(1)); |
601 EXPECT_EQ(0xFFFF, str16.CharAt(2)); | 601 EXPECT_EQ(0xFFFF, str16.CharAt(2)); |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 | 605 |
| 606 TEST_CASE(StringFormat) { |
| 607 const char* hello_str = "Hello World!"; |
| 608 int32_t hello_len = strlen(hello_str); |
| 609 const String& str = |
| 610 String::Handle(String::NewFormatted("Hello %s!", "World")); |
| 611 EXPECT(str.IsInstance()); |
| 612 EXPECT(str.IsString()); |
| 613 EXPECT(str.IsOneByteString()); |
| 614 EXPECT(!str.IsTwoByteString()); |
| 615 EXPECT(!str.IsFourByteString()); |
| 616 EXPECT(!str.IsNumber()); |
| 617 EXPECT(str.Equals(hello_str)); |
| 618 } |
| 619 |
| 620 |
606 TEST_CASE(StringConcat) { | 621 TEST_CASE(StringConcat) { |
607 // Create strings from concatenated 1-byte empty strings. | 622 // Create strings from concatenated 1-byte empty strings. |
608 { | 623 { |
609 const String& empty1 = String::Handle(String::New("")); | 624 const String& empty1 = String::Handle(String::New("")); |
610 EXPECT(empty1.IsOneByteString()); | 625 EXPECT(empty1.IsOneByteString()); |
611 EXPECT_EQ(0, empty1.Length()); | 626 EXPECT_EQ(0, empty1.Length()); |
612 | 627 |
613 const String& empty2 = String::Handle(String::New("")); | 628 const String& empty2 = String::Handle(String::New("")); |
614 EXPECT(empty2.IsOneByteString()); | 629 EXPECT(empty2.IsOneByteString()); |
615 EXPECT_EQ(0, empty2.Length()); | 630 EXPECT_EQ(0, empty2.Length()); |
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2785 EXPECT_EQ(2, test_classes.length()); | 2800 EXPECT_EQ(2, test_classes.length()); |
2786 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); | 2801 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); |
2787 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); | 2802 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); |
2788 EXPECT_EQ(target1.raw(), test_target.raw()); | 2803 EXPECT_EQ(target1.raw(), test_target.raw()); |
2789 } | 2804 } |
2790 | 2805 |
2791 | 2806 |
2792 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2807 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2793 | 2808 |
2794 } // namespace dart | 2809 } // namespace dart |
OLD | NEW |