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

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

Issue 1341473002: Fix a variety of service protocol bugs. (Closed) Base URL: git@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 unified diff | Download patch
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/object.cc » ('j') | 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 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 10
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 293
294 TEST_CASE(JSON_JSONStream_DartObject) { 294 TEST_CASE(JSON_JSONStream_DartObject) {
295 JSONStream js; 295 JSONStream js;
296 { 296 {
297 JSONArray jsarr(&js); 297 JSONArray jsarr(&js);
298 jsarr.AddValue(Object::Handle(Object::null())); 298 jsarr.AddValue(Object::Handle(Object::null()));
299 JSONObject jsobj(&jsarr); 299 JSONObject jsobj(&jsarr);
300 jsobj.AddProperty("object_key", Object::Handle(Object::null())); 300 jsobj.AddProperty("object_key", Object::Handle(Object::null()));
301 } 301 }
302 char buffer[1024];
303 ElideJSONSubstring("classes", js.ToCString(), buffer);
302 EXPECT_STREQ("[{\"type\":\"@Instance\"," 304 EXPECT_STREQ("[{\"type\":\"@Instance\","
303 "\"_vmType\":\"null\"," 305 "\"_vmType\":\"null\","
306 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
307 "\"name\":\"Null\"},"
304 "\"kind\":\"Null\"," 308 "\"kind\":\"Null\","
305 "\"fixedId\":true," 309 "\"fixedId\":true,"
306 "\"id\":\"objects\\/null\"," 310 "\"id\":\"objects\\/null\","
307 "\"valueAsString\":\"null\"}," 311 "\"valueAsString\":\"null\"},"
308 "{\"object_key\":" 312 "{\"object_key\":"
309 "{\"type\":\"@Instance\"," 313 "{\"type\":\"@Instance\","
310 "\"_vmType\":\"null\"," 314 "\"_vmType\":\"null\","
315 "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\","
316 "\"name\":\"Null\"},"
311 "\"kind\":\"Null\"," 317 "\"kind\":\"Null\","
312 "\"fixedId\":true," 318 "\"fixedId\":true,"
313 "\"id\":\"objects\\/null\"," 319 "\"id\":\"objects\\/null\","
314 "\"valueAsString\":\"null\"}}]", 320 "\"valueAsString\":\"null\"}}]",
315 js.ToCString()); 321 buffer);
316 } 322 }
317 323
318 TEST_CASE(JSON_JSONStream_EscapedString) { 324 TEST_CASE(JSON_JSONStream_EscapedString) {
319 JSONStream js; 325 JSONStream js;
320 { 326 {
321 JSONArray jsarr(&js); 327 JSONArray jsarr(&js);
322 jsarr.AddValue("Hel\"\"lo\r\n\t"); 328 jsarr.AddValue("Hel\"\"lo\r\n\t");
323 } 329 }
324 EXPECT_STREQ("[\"Hel\\\"\\\"lo\\r\\n\\t\"]", js.ToCString()); 330 EXPECT_STREQ("[\"Hel\\\"\\\"lo\\r\\n\\t\"]", js.ToCString());
325 } 331 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 js.SetParams(&param_keys[0], &param_values[0], 2); 414 js.SetParams(&param_keys[0], &param_values[0], 2);
409 EXPECT(js.num_params() == 2); 415 EXPECT(js.num_params() == 2);
410 EXPECT(!js.HasParam("lizard")); 416 EXPECT(!js.HasParam("lizard"));
411 EXPECT(js.HasParam("dog")); 417 EXPECT(js.HasParam("dog"));
412 EXPECT(js.HasParam("cat")); 418 EXPECT(js.HasParam("cat"));
413 EXPECT(js.ParamIs("cat", "banana")); 419 EXPECT(js.ParamIs("cat", "banana"));
414 EXPECT(!js.ParamIs("dog", "banana")); 420 EXPECT(!js.ParamIs("dog", "banana"));
415 } 421 }
416 422
417 } // namespace dart 423 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698