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/text_buffer.h" | 6 #include "platform/text_buffer.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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 EXPECT(js.num_params() == 0); | 308 EXPECT(js.num_params() == 0); |
309 js.SetParams(¶m_keys[0], ¶m_values[0], 2); | 309 js.SetParams(¶m_keys[0], ¶m_values[0], 2); |
310 EXPECT(js.num_params() == 2); | 310 EXPECT(js.num_params() == 2); |
311 EXPECT(!js.HasParam("lizard")); | 311 EXPECT(!js.HasParam("lizard")); |
312 EXPECT(js.HasParam("dog")); | 312 EXPECT(js.HasParam("dog")); |
313 EXPECT(js.HasParam("cat")); | 313 EXPECT(js.HasParam("cat")); |
314 EXPECT(js.ParamIs("cat", "banana")); | 314 EXPECT(js.ParamIs("cat", "banana")); |
315 EXPECT(!js.ParamIs("dog", "banana")); | 315 EXPECT(!js.ParamIs("dog", "banana")); |
316 } | 316 } |
317 | 317 |
| 318 |
| 319 TEST_CASE(JSON_JSONStream_AppendJSONStreamConsumer) { |
| 320 JSONStream js; |
| 321 |
| 322 { |
| 323 JSONObject obj(&js); |
| 324 { |
| 325 JSONArray arr(&obj, "test"); |
| 326 const char* test_data = "{a, b, c},"; |
| 327 AppendJSONStreamConsumer(Dart_StreamConsumer_kData, "", |
| 328 reinterpret_cast<const uint8_t*>(&test_data[0]), |
| 329 strlen(test_data), |
| 330 &js); |
| 331 AppendJSONStreamConsumer(Dart_StreamConsumer_kData, "", |
| 332 reinterpret_cast<const uint8_t*>(&test_data[0]), |
| 333 strlen(test_data), |
| 334 &js); |
| 335 AppendJSONStreamConsumer(Dart_StreamConsumer_kData, "", |
| 336 reinterpret_cast<const uint8_t*>(&test_data[0]), |
| 337 strlen(test_data) - 1, |
| 338 &js); |
| 339 } |
| 340 } |
| 341 |
| 342 EXPECT_STREQ("{\"test\":[{a, b, c},{a, b, c},{a, b, c}]}", js.ToCString()); |
| 343 } |
| 344 |
318 #endif // !PRODUCT | 345 #endif // !PRODUCT |
319 | 346 |
320 } // namespace dart | 347 } // namespace dart |
OLD | NEW |