| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 { | 383 { |
| 384 JSONObject jsobj(&js); | 384 JSONObject jsobj(&js); |
| 385 jsobj.AddPropertyStr("nullInMiddle", obj); | 385 jsobj.AddPropertyStr("nullInMiddle", obj); |
| 386 } | 386 } |
| 387 EXPECT_STREQ("{\"nullInMiddle\":\"This has\\u0000 four words.\"}", | 387 EXPECT_STREQ("{\"nullInMiddle\":\"This has\\u0000 four words.\"}", |
| 388 js.ToCString()); | 388 js.ToCString()); |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| 393 TEST_CASE(JSON_JSONStream_Options) { | 393 TEST_CASE(JSON_JSONStream_Params) { |
| 394 const char* arguments[] = {"a", "b", "c"}; | 394 const char* param_keys[] = {"dog", "cat"}; |
| 395 const char* option_keys[] = {"dog", "cat"}; | 395 const char* param_values[] = {"apple", "banana"}; |
| 396 const char* option_values[] = {"apple", "banana"}; | |
| 397 | 396 |
| 398 JSONStream js; | 397 JSONStream js; |
| 399 EXPECT(js.num_arguments() == 0); | 398 EXPECT(js.num_params() == 0); |
| 400 js.SetArguments(&arguments[0], 3); | 399 js.SetParams(¶m_keys[0], ¶m_values[0], 2); |
| 401 EXPECT(js.num_arguments() == 3); | 400 EXPECT(js.num_params() == 2); |
| 402 EXPECT_STREQ("a", js.command()); | 401 EXPECT(!js.HasParam("lizard")); |
| 403 | 402 EXPECT(js.HasParam("dog")); |
| 404 EXPECT(js.num_options() == 0); | 403 EXPECT(js.HasParam("cat")); |
| 405 js.SetOptions(&option_keys[0], &option_values[0], 2); | 404 EXPECT(js.ParamIs("cat", "banana")); |
| 406 EXPECT(js.num_options() == 2); | 405 EXPECT(!js.ParamIs("dog", "banana")); |
| 407 EXPECT(!js.HasOption("lizard")); | |
| 408 EXPECT(js.HasOption("dog")); | |
| 409 EXPECT(js.HasOption("cat")); | |
| 410 EXPECT(js.OptionIs("cat", "banana")); | |
| 411 EXPECT(!js.OptionIs("dog", "banana")); | |
| 412 } | 406 } |
| 413 | 407 |
| 414 } // namespace dart | 408 } // namespace dart |
| OLD | NEW |