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

Unified Diff: runtime/vm/json_test.cc

Issue 2081433002: Use official JSON encoding for stream (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixed & Added UTF-32 characters tests Created 4 years, 6 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/json_stream.cc ('k') | runtime/vm/unicode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/json_test.cc
diff --git a/runtime/vm/json_test.cc b/runtime/vm/json_test.cc
index e8c4f5d959a52812890373d21543ee83526858fe..a0b27c207548b28773d5d1c25368375d0af6a38d 100644
--- a/runtime/vm/json_test.cc
+++ b/runtime/vm/json_test.cc
@@ -219,8 +219,9 @@ TEST_CASE(JSON_JSONStream_DartString) {
"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"
+ "var surrogates = '\\u{1D11E}\\u{1D11E}\\u{1D11E}"
+ "\\u{1D11E}\\u{1D11E}';\n"
+ "var wrongEncoding = '\\u{1D11E}' + surrogates[0] + '\\u{1D11E}';"
"var nullInMiddle = 'This has\\u0000 four words.';";
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
@@ -265,9 +266,7 @@ TEST_CASE(JSON_JSONStream_DartString) {
JSONObject jsobj(&js);
EXPECT(!jsobj.AddPropertyStr("unicode", obj));
}
- EXPECT_STREQ("{\"unicode\":\"\\u00CE\\u00F1\\u0163\\u00E9r\\u00F1\\u00E5"
- "\\u0163\\u00EE\\u00F6\\u00F1\\u00E5\\u013C\\u00EE\\u017E"
- "\\u00E5\\u0163\\u00EE\\u1EDD\\u00F1\"}", js.ToCString());
+ EXPECT_STREQ("{\"unicode\":\"Îñţérñåţîöñåļîžåţîờñ\"}", js.ToCString());
}
{
@@ -280,11 +279,24 @@ TEST_CASE(JSON_JSONStream_DartString) {
JSONObject jsobj(&js);
EXPECT(!jsobj.AddPropertyStr("surrogates", obj));
}
- EXPECT_STREQ("{\"surrogates\":\"\\uD834\\uDD1E\\uD834\\uDD1E\\uD834\\uDD1E"
- "\\uD834\\uDD1E\\uD834\\uDD1E\"}", js.ToCString());
+ EXPECT_STREQ("{\"surrogates\":\"𝄞𝄞𝄞𝄞𝄞\"}", js.ToCString());
}
{
+ result = Dart_GetField(lib, NewString("wrongEncoding"));
+ EXPECT_VALID(result);
+ obj ^= Api::UnwrapHandle(result);
+
+ JSONStream js;
+ {
+ JSONObject jsobj(&js);
+ EXPECT(!jsobj.AddPropertyStr("wrongEncoding", obj));
+ }
+ EXPECT_STREQ("{\"wrongEncoding\":\"𝄞\\uD834𝄞\"}", js.ToCString());
+ }
+
+
+ {
result = Dart_GetField(lib, NewString("nullInMiddle"));
EXPECT_VALID(result);
obj ^= Api::UnwrapHandle(result);
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698