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

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

Issue 22599002: Escape strings when writing to JSON. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | no next file » | 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/assert.h" 5 #include "platform/assert.h"
6 #include "platform/json.h" 6 #include "platform/json.h"
7 #include "vm/json_stream.h" 7 #include "vm/json_stream.h"
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 JSONStream js(&tb); 244 JSONStream js(&tb);
245 js.OpenArray(); 245 js.OpenArray();
246 js.PrintValue(Object::Handle(Object::null())); 246 js.PrintValue(Object::Handle(Object::null()));
247 js.OpenObject(); 247 js.OpenObject();
248 js.PrintProperty("object_key", Object::Handle(Object::null())); 248 js.PrintProperty("object_key", Object::Handle(Object::null()));
249 js.CloseArray(); 249 js.CloseArray();
250 EXPECT_STREQ("[{\"type\":\"null\"},{\"object_key\":{\"type\":\"null\"}]", 250 EXPECT_STREQ("[{\"type\":\"null\"},{\"object_key\":{\"type\":\"null\"}]",
251 tb.buf()); 251 tb.buf());
252 } 252 }
253 253
254 TEST_CASE(JSON_JSONStream_EscapedString) {
255 TextBuffer tb(256);
256 JSONStream js(&tb);
257 js.PrintValue("Hel\"\"lo\r\n\t");
258 EXPECT_STREQ("\"Hel\\\"\\\"lo\\r\\n\\t\"", tb.buf());
259 }
260
254 261
255 } // namespace dart 262 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698