Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: runtime/vm/json_test.cc

Issue 897193002: Finish moving service protocol to json rpc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(&param_keys[0], &param_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
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.cc ('k') | runtime/vm/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698