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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/symbols.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object_test.cc
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index 4b34413219ebc4c9c965c79ac99a858ee3162860..5e006a0855fed675d15abee2d08c4d06c4796ac3 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -4709,4 +4709,76 @@ TEST_CASE(LinkedHashMap_iteration) {
EXPECT(!iterator.MoveNext());
}
+
+static void CheckConcatAll(const String* data[], intptr_t n) {
+ Zone* zone = Thread::Current()->zone();
+ GrowableHandlePtrArray<const String> pieces(zone, n);
+ const Array& array = Array::Handle(zone, Array::New(n));
+ for (int i = 0; i < n; i++) {
+ pieces.Add(*data[i]);
+ array.SetAt(i, *data[i]);
+ }
+ const String& res1 = String::Handle(zone, Symbols::FromConcatAll(pieces));
+ const String& res2 = String::Handle(zone, String::ConcatAll(array));
+ EXPECT(res1.Equals(res2));
+}
+
+
+TEST_CASE(Symbols_FromConcatAll) {
+ {
+ const String* data[3] = { &Symbols::FallThroughError(),
+ &Symbols::Dot(),
+ &Symbols::isPaused() };
+ CheckConcatAll(data, 3);
+ }
+
+ {
+ const intptr_t kWideCharsLen = 7;
+ uint16_t wide_chars[kWideCharsLen] = { 'H', 'e', 'l', 'l', 'o', 256, '!' };
+ const String& two_str = String::Handle(String::FromUTF16(wide_chars,
+ kWideCharsLen));
+
+ const String* data[3] = { &two_str, &Symbols::Dot(), &two_str };
+ CheckConcatAll(data, 3);
+ }
+
+ {
+ uint8_t characters[] = { 0xF6, 0xF1, 0xE9 };
+ intptr_t len = ARRAY_SIZE(characters);
+
+ const String& str = String::Handle(
+ ExternalOneByteString::New(characters, len, NULL, NULL, Heap::kNew));
+ const String* data[3] = { &str, &Symbols::Dot(), &str };
+ CheckConcatAll(data, 3);
+ }
+
+ {
+ uint16_t characters[] =
+ { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' };
+ intptr_t len = ARRAY_SIZE(characters);
+
+ const String& str = String::Handle(
+ ExternalTwoByteString::New(characters, len, NULL, NULL, Heap::kNew));
+ const String* data[3] = { &str, &Symbols::Dot(), &str };
+ CheckConcatAll(data, 3);
+ }
+
+ {
+ uint8_t characters1[] = { 0xF6, 0xF1, 0xE9 };
+ intptr_t len1 = ARRAY_SIZE(characters1);
+
+ const String& str1 = String::Handle(
+ ExternalOneByteString::New(characters1, len1, NULL, NULL, Heap::kNew));
+
+ uint16_t characters2[] =
+ { 'a', '\n', '\f', '\b', '\t', '\v', '\r', '\\', '$', 'z' };
+ intptr_t len2 = ARRAY_SIZE(characters2);
+
+ const String& str2 = String::Handle(
+ ExternalTwoByteString::New(characters2, len2, NULL, NULL, Heap::kNew));
+ const String* data[3] = { &str1, &Symbols::Dot(), &str2 };
+ CheckConcatAll(data, 3);
+ }
+}
+
} // namespace dart
« 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