Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: runtime/vm/object_test.cc

Issue 1323063004: Fix Dartium by supporting external strings as well in Symbols::FromConcatAll (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add assert Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/symbols.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 4691 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 4702
4703 EXPECT(iterator.MoveNext()); 4703 EXPECT(iterator.MoveNext());
4704 object = iterator.CurrentKey(); 4704 object = iterator.CurrentKey();
4705 EXPECT_STREQ("z", object.ToCString()); 4705 EXPECT_STREQ("z", object.ToCString());
4706 object = iterator.CurrentValue(); 4706 object = iterator.CurrentValue();
4707 EXPECT_STREQ("5", object.ToCString()); 4707 EXPECT_STREQ("5", object.ToCString());
4708 4708
4709 EXPECT(!iterator.MoveNext()); 4709 EXPECT(!iterator.MoveNext());
4710 } 4710 }
4711 4711
4712
4713 static void CheckConcatAll(const String* data[], intptr_t n) {
4714 Zone* zone = Thread::Current()->zone();
4715 GrowableHandlePtrArray<const String> pieces(zone, n);
4716 const Array& array = Array::Handle(zone, Array::New(n));
4717 for (int i = 0; i < n; i++) {
4718 pieces.Add(*data[i]);
4719 array.SetAt(i, *data[i]);
4720 }
4721 const String& res1 = String::Handle(zone, Symbols::FromConcatAll(pieces));
4722 const String& res2 = String::Handle(zone, String::ConcatAll(array));
4723 EXPECT(res1.Equals(res2));
4724 }
4725
4726
4727 TEST_CASE(Symbols_FromConcatAll) {
4728 {
4729 const String* data[3] = { &Symbols::FallThroughError(),
4730 &Symbols::Dot(),
4731 &Symbols::isPaused() };
4732 CheckConcatAll(data, 3);
4733 }
4734
4735 {
4736 const intptr_t kWideCharsLen = 7;
4737 uint16_t wide_chars[kWideCharsLen] = { 'H', 'e', 'l', 'l', 'o', 256, '!' };
4738 const String& two_str = String::Handle(String::FromUTF16(wide_chars,
4739 kWideCharsLen));
4740
4741 const String* data[3] = { &two_str, &Symbols::Dot(), &two_str };
4742 CheckConcatAll(data, 3);
4743 }
4744
4745 {
4746 uint8_t characters[] = { 0xF6, 0xF1, 0xE9 };
4747 intptr_t len = ARRAY_SIZE(characters);
4748
4749 const String& str = String::Handle(
4750 ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew));
4751 const String* data[3] = { &str, &Symbols::Dot(), &str };
4752 CheckConcatAll(data, 3);
4753 }
4754
4755 {
4756 uint16_t characters[] =
4757 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' };
4758 intptr_t len = ARRAY_SIZE(characters);
4759
4760 const String& str = String::Handle(
4761 ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew));
4762 const String* data[3] = { &str, &Symbols::Dot(), &str };
4763 CheckConcatAll(data, 3);
4764 }
4765
4766 {
4767 uint8_t characters1[] = { 0xF6, 0xF1, 0xE9 };
4768 intptr_t len1 = ARRAY_SIZE(characters1);
4769
4770 const String& str1 = String::Handle(
4771 ExternalOneByteString::New(characters1, len1, NULL, NULL, Heap::kNew));
4772
4773 uint16_t characters2[] =
4774 { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' };
4775 intptr_t len2 = ARRAY_SIZE(characters2);
4776
4777 const String& str2 = String::Handle(
4778 ExternalTwoByteString::New(characters2, len2, NULL, NULL, Heap::kNew));
4779 const String* data[3] = { &str1, &Symbols::Dot(), &str2 };
4780 CheckConcatAll(data, 3);
4781 }
4782 }
4783
4712 } // namespace dart 4784 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698