OLD | NEW |
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 Loading... |
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 Loading... |
408 js.SetParams(¶m_keys[0], ¶m_values[0], 2); | 414 js.SetParams(¶m_keys[0], ¶m_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 |
OLD | NEW |