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) { | |
siva
2012/03/13 19:45:21
const char* hello_str = "Hello World!";
int32_t he
turnidge
2012/03/13 21:23:37
Done.
| |
607 int32_t hello_len = strlen("Hello World!"); | |
608 const String& str = String::Handle(String::NewFormat("Hello %s!", "World")); | |
609 EXPECT(str.IsInstance()); | |
610 EXPECT(str.IsString()); | |
611 EXPECT(str.IsOneByteString()); | |
612 EXPECT(!str.IsTwoByteString()); | |
613 EXPECT(!str.IsFourByteString()); | |
614 EXPECT(!str.IsNumber()); | |
615 EXPECT_EQ(hello_len, str.Length()); | |
616 EXPECT_EQ('H', str.CharAt(0)); | |
617 EXPECT_EQ('e', str.CharAt(1)); | |
618 EXPECT_EQ('l', str.CharAt(2)); | |
619 EXPECT_EQ('l', str.CharAt(3)); | |
620 EXPECT_EQ('o', str.CharAt(4)); | |
621 EXPECT_EQ(' ', str.CharAt(5)); | |
622 EXPECT_EQ('W', str.CharAt(6)); | |
623 EXPECT_EQ('o', str.CharAt(7)); | |
624 EXPECT_EQ('r', str.CharAt(8)); | |
625 EXPECT_EQ('l', str.CharAt(9)); | |
626 EXPECT_EQ('d', str.CharAt(10)); | |
627 EXPECT_EQ('!', str.CharAt(11)); | |
siva
2012/03/13 19:45:21
EXPECT_EQ(str.Equals(hello_str));
instead of thes
turnidge
2012/03/13 21:23:37
Just mimicking existing tests. Didn't realize we
| |
628 } | |
629 | |
630 | |
606 TEST_CASE(StringConcat) { | 631 TEST_CASE(StringConcat) { |
607 // Create strings from concatenated 1-byte empty strings. | 632 // Create strings from concatenated 1-byte empty strings. |
608 { | 633 { |
609 const String& empty1 = String::Handle(String::New("")); | 634 const String& empty1 = String::Handle(String::New("")); |
610 EXPECT(empty1.IsOneByteString()); | 635 EXPECT(empty1.IsOneByteString()); |
611 EXPECT_EQ(0, empty1.Length()); | 636 EXPECT_EQ(0, empty1.Length()); |
612 | 637 |
613 const String& empty2 = String::Handle(String::New("")); | 638 const String& empty2 = String::Handle(String::New("")); |
614 EXPECT(empty2.IsOneByteString()); | 639 EXPECT(empty2.IsOneByteString()); |
615 EXPECT_EQ(0, empty2.Length()); | 640 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()); | 2810 EXPECT_EQ(2, test_classes.length()); |
2786 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); | 2811 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); |
2787 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); | 2812 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); |
2788 EXPECT_EQ(target1.raw(), test_target.raw()); | 2813 EXPECT_EQ(target1.raw(), test_target.raw()); |
2789 } | 2814 } |
2790 | 2815 |
2791 | 2816 |
2792 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2817 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2793 | 2818 |
2794 } // namespace dart | 2819 } // namespace dart |
OLD | NEW |