| 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 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 | 292 |
| 293 TEST_CASE(JSON_JSONStream_DartObject) { | 293 TEST_CASE(JSON_JSONStream_DartObject) { |
| 294 JSONStream js; | 294 JSONStream js; |
| 295 { | 295 { |
| 296 JSONArray jsarr(&js); | 296 JSONArray jsarr(&js); |
| 297 jsarr.AddValue(Object::Handle(Object::null())); | 297 jsarr.AddValue(Object::Handle(Object::null())); |
| 298 JSONObject jsobj(&jsarr); | 298 JSONObject jsobj(&jsarr); |
| 299 jsobj.AddProperty("object_key", Object::Handle(Object::null())); | 299 jsobj.AddProperty("object_key", Object::Handle(Object::null())); |
| 300 } | 300 } |
| 301 EXPECT_STREQ("[{\"type\":\"@Null\",\"id\":\"objects\\/null\"," | 301 EXPECT_STREQ("[{\"type\":\"@null\",\"id\":\"objects\\/null\"," |
| 302 "\"valueAsString\":\"null\"}," | 302 "\"valueAsString\":\"null\"}," |
| 303 "{\"object_key\":{\"type\":\"@Null\",\"id\":\"objects\\/null\"," | 303 "{\"object_key\":{\"type\":\"@null\",\"id\":\"objects\\/null\"," |
| 304 "\"valueAsString\":\"null\"}}]", | 304 "\"valueAsString\":\"null\"}}]", |
| 305 js.ToCString()); | 305 js.ToCString()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TEST_CASE(JSON_JSONStream_EscapedString) { | 308 TEST_CASE(JSON_JSONStream_EscapedString) { |
| 309 JSONStream js; | 309 JSONStream js; |
| 310 { | 310 { |
| 311 JSONArray jsarr(&js); | 311 JSONArray jsarr(&js); |
| 312 jsarr.AddValue("Hel\"\"lo\r\n\t"); | 312 jsarr.AddValue("Hel\"\"lo\r\n\t"); |
| 313 } | 313 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 330 js.SetOptions(&option_keys[0], &option_values[0], 3); | 330 js.SetOptions(&option_keys[0], &option_values[0], 3); |
| 331 EXPECT(js.num_options() == 3); | 331 EXPECT(js.num_options() == 3); |
| 332 EXPECT(!js.HasOption("lizard")); | 332 EXPECT(!js.HasOption("lizard")); |
| 333 EXPECT(js.HasOption("dog")); | 333 EXPECT(js.HasOption("dog")); |
| 334 EXPECT(js.HasOption("cat")); | 334 EXPECT(js.HasOption("cat")); |
| 335 EXPECT(js.OptionIs("cat", "banana")); | 335 EXPECT(js.OptionIs("cat", "banana")); |
| 336 EXPECT(!js.OptionIs("dog", "banana")); | 336 EXPECT(!js.OptionIs("dog", "banana")); |
| 337 } | 337 } |
| 338 | 338 |
| 339 } // namespace dart | 339 } // namespace dart |
| OLD | NEW |