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

Unified Diff: runtime/vm/object_test.cc

Issue 558853004: Preserve the contents of Dart strings with unmatched surrogate halfs by avoiding a UTF16 -> UTF8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: sync and build Created 6 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.cc ('k') | no next file » | 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 f67f91b5f545f375a85d13c3471ce4f59727e40f..c6773d074cc260284ac5e3ddf43f6dd12ab2f3e5 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -4109,66 +4109,6 @@ TEST_CASE(SpecialClassesHaveEmptyArrays) {
}
-TEST_CASE(ToCStringTruncated) {
- const char* kScriptChars =
- "var ascii = 'Hello, World!';\n"
- "var unicode = '\\u00CE\\u00F1\\u0163\\u00E9r\\u00F1\\u00E5\\u0163"
- "\\u00EE\\u00F6\\u00F1\\u00E5\\u013C\\u00EE\\u017E\\u00E5\\u0163"
- "\\u00EE\\u1EDD\\u00F1';\n"
- "var surrogates ='\\u{1D11E}\\u{1D11E}\\u{1D11E}\\u{1D11E}"\
- "\\u{1D11E}';\n";
-
- Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
- EXPECT_VALID(lib);
-
- String& obj = String::Handle();
- Dart_Handle result;
- bool did_truncate;
- intptr_t length;
-
- result = Dart_GetField(lib, NewString("ascii"));
- EXPECT_VALID(result);
- obj ^= Api::UnwrapHandle(result);
- EXPECT_STREQ("Hello, World!",
- obj.ToCStringTruncated(100, &did_truncate, &length));
- EXPECT(!did_truncate);
- EXPECT_EQ(13, length);
- EXPECT_STREQ("Hel", obj.ToCStringTruncated(3, &did_truncate, &length));
- EXPECT(did_truncate);
- EXPECT_EQ(3, length);
-
- result = Dart_GetField(lib, NewString("unicode"));
- EXPECT_VALID(result);
- obj ^= Api::UnwrapHandle(result);
- EXPECT_STREQ("\u00CE\u00F1\u0163\u00E9r\u00F1\u00E5\u0163"
- "\u00EE\u00F6\u00F1\u00E5\u013C\u00EE\u017E\u00E5\u0163"
- "\u00EE\u1EDD\u00F1",
- obj.ToCStringTruncated(100, &did_truncate, &length));
- EXPECT(!did_truncate);
- EXPECT_EQ(40, length);
- EXPECT_STREQ("\u00CE\u00F1\u0163",
- obj.ToCStringTruncated(3, &did_truncate, &length));
- EXPECT(did_truncate);
- EXPECT_EQ(6, length);
-
- result = Dart_GetField(lib, NewString("surrogates"));
- EXPECT_VALID(result);
- obj ^= Api::UnwrapHandle(result);
- EXPECT_STREQ("\U0001D11E\U0001D11E\U0001D11E\U0001D11E\U0001D11E",
- obj.ToCStringTruncated(100, &did_truncate, &length));
- EXPECT(!did_truncate);
- EXPECT_EQ(20, length);
- EXPECT_STREQ("\U0001D11E",
- obj.ToCStringTruncated(3, &did_truncate, &length));
- EXPECT(did_truncate);
- EXPECT_EQ(4, length); // 3 code units would be in the middle of a surrogate
- // pair, so it gets rounded down 2 code units.
- EXPECT_STREQ("\U0001D11E\U0001D11E",
- obj.ToCStringTruncated(4, &did_truncate, &length));
- EXPECT(did_truncate);
- EXPECT_EQ(8, length);
-}
-
class ObjectAccumulator : public ObjectVisitor {
public:
explicit ObjectAccumulator(GrowableArray<Object*>* objects)
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698