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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 TEST_CASE(JSON_JSONStream_EscapedString) { | 305 TEST_CASE(JSON_JSONStream_EscapedString) { |
306 JSONStream js; | 306 JSONStream js; |
307 { | 307 { |
308 JSONArray jsarr(&js); | 308 JSONArray jsarr(&js); |
309 jsarr.AddValue("Hel\"\"lo\r\n\t"); | 309 jsarr.AddValue("Hel\"\"lo\r\n\t"); |
310 } | 310 } |
311 EXPECT_STREQ("[\"Hel\\\"\\\"lo\\r\\n\\t\"]", js.ToCString()); | 311 EXPECT_STREQ("[\"Hel\\\"\\\"lo\\r\\n\\t\"]", js.ToCString()); |
312 } | 312 } |
313 | 313 |
314 | 314 |
| 315 TEST_CASE(JSON_JSONStream_Options) { |
| 316 const char* arguments[] = {"a", "b", "c"}; |
| 317 const char* option_keys[] = {"dog", "cat"}; |
| 318 const char* option_values[] = {"apple", "banana"}; |
| 319 |
| 320 JSONStream js; |
| 321 EXPECT(js.num_arguments() == 0); |
| 322 js.SetArguments(&arguments[0], 3); |
| 323 EXPECT(js.num_arguments() == 3); |
| 324 EXPECT_STREQ("a", js.command()); |
| 325 |
| 326 EXPECT(js.num_options() == 0); |
| 327 js.SetOptions(&option_keys[0], &option_values[0], 3); |
| 328 EXPECT(js.num_options() == 3); |
| 329 EXPECT(!js.HasOption("lizard")); |
| 330 EXPECT(js.HasOption("dog")); |
| 331 EXPECT(js.HasOption("cat")); |
| 332 EXPECT(js.OptionIs("cat", "banana")); |
| 333 EXPECT(!js.OptionIs("dog", "banana")); |
| 334 } |
| 335 |
315 } // namespace dart | 336 } // namespace dart |
OLD | NEW |