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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1330533002: Revert "Allow individual unicode surrogates strings" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | runtime/vm/unicode.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index b9ad3f3287f0c162f0ee305cda31460b57342a72..8ea4e6833dd8d719f1daf6c2ce883195a1a4e16d 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1107,22 +1107,13 @@ TEST_CASE(NewString) {
TEST_CASE(MalformedStringToUTF8) {
- // 1D11E = treble clef
- // [0] should be high surrogate D834
- // [1] should be low surrogate DD1E
- // Strings are allowed to have individual or out of order surrogates, even
- // if that doesn't make sense as renderable characters.
const char* kScriptChars =
- "String lowSurrogate() {"
+ "String testMain() {"
" return '\\u{1D11E}'[1];"
- "}"
- "String highSurrogate() {"
- " return '\\u{1D11E}'[0];"
- "}"
- "String reversed() => lowSurrogate() + highSurrogate();";
+ "}";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
- Dart_Handle str1 = Dart_Invoke(lib, NewString("lowSurrogate"), 0, NULL);
+ Dart_Handle str1 = Dart_Invoke(lib, NewString("testMain"), 0, NULL);
EXPECT_VALID(str1);
uint8_t* utf8_encoded = NULL;
@@ -1135,20 +1126,7 @@ TEST_CASE(MalformedStringToUTF8) {
EXPECT_EQ(158, static_cast<intptr_t>(utf8_encoded[2]));
Dart_Handle str2 = Dart_NewStringFromUTF8(utf8_encoded, utf8_length);
- EXPECT_VALID(str2); // Standalone low surrogate, but still valid
-
- Dart_Handle reversed = Dart_Invoke(lib, NewString("reversed"), 0, NULL);
- EXPECT_VALID(reversed); // This is also allowed.
- uint8_t* utf8_encoded_reversed = NULL;
- intptr_t utf8_length_reversed = 0;
- result = Dart_StringToUTF8(reversed,
- &utf8_encoded_reversed, &utf8_length_reversed);
- EXPECT_VALID(result);
- EXPECT_EQ(6, utf8_length_reversed);
- uint8_t expected[6] = {237, 180, 158, 237, 160, 180};
- for (int i = 0; i < 6; i++) {
- EXPECT_EQ(expected[i], utf8_encoded_reversed[i]);
- }
+ EXPECT(Dart_IsError(str2)); // Invalid UTF-8.
}
« no previous file with comments | « no previous file | runtime/vm/unicode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698