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

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

Issue 19870006: Support stacktrace and objecthistogram service commands (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
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 9
10 namespace dart { 10 namespace dart {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 js.Clear(); 135 js.Clear();
136 js.PrintValueBool(true); 136 js.PrintValueBool(true);
137 EXPECT_STREQ("true", tb.buf()); 137 EXPECT_STREQ("true", tb.buf());
138 138
139 js.Clear(); 139 js.Clear();
140 js.PrintValueBool(false); 140 js.PrintValueBool(false);
141 EXPECT_STREQ("false", tb.buf()); 141 EXPECT_STREQ("false", tb.buf());
142 142
143 js.Clear(); 143 js.Clear();
144 js.PrintValue((intptr_t)4); 144 js.PrintValue(static_cast<intptr_t>(4));
145 EXPECT_STREQ("4", tb.buf()); 145 EXPECT_STREQ("4", tb.buf());
146 146
147 js.Clear(); 147 js.Clear();
148 js.PrintValue(1.0); 148 js.PrintValue(1.0);
149 EXPECT_STREQ("1.000000", tb.buf()); 149 EXPECT_STREQ("1.000000", tb.buf());
150 150
151 js.Clear(); 151 js.Clear();
152 js.PrintValue("hello"); 152 js.PrintValue("hello");
153 EXPECT_STREQ("\"hello\"", tb.buf()); 153 EXPECT_STREQ("\"hello\"", tb.buf());
154 } 154 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 js.PrintValue((intptr_t)4); 212 js.PrintValue((intptr_t)4);
213 js.CloseArray(); 213 js.CloseArray();
214 js.OpenArray(); 214 js.OpenArray();
215 js.PrintValueBool(false); 215 js.PrintValueBool(false);
216 js.CloseArray(); 216 js.CloseArray();
217 js.CloseArray(); 217 js.CloseArray();
218 EXPECT_STREQ("[[4],[false]]", tb.buf()); 218 EXPECT_STREQ("[[4],[false]]", tb.buf());
219 } 219 }
220 220
221 221
222 TEST_CASE(JSON_JSONStream_Printf) {
223 TextBuffer tb(256);
224 JSONStream js(&tb);
225 js.OpenArray();
226 js.PrintfValue("%d %s", 2, "hello");
227 js.CloseArray();
228 EXPECT_STREQ("[\"2 hello\"]", tb.buf());
229 }
230
231
232 TEST_CASE(JSON_JSONStream_ObjectPrintf) {
233 TextBuffer tb(256);
234 JSONStream js(&tb);
235 js.OpenObject();
236 js.PrintfProperty("key", "%d %s", 2, "hello");
237 js.CloseObject();
238 EXPECT_STREQ("{\"key\":\"2 hello\"}", tb.buf());
239 }
240
241
222 TEST_CASE(JSON_JSONStream_DartObject) { 242 TEST_CASE(JSON_JSONStream_DartObject) {
223 TextBuffer tb(256); 243 TextBuffer tb(256);
224 JSONStream js(&tb); 244 JSONStream js(&tb);
225 js.OpenArray(); 245 js.OpenArray();
226 js.PrintValue(Object::Handle(Object::null())); 246 js.PrintValue(Object::Handle(Object::null()));
227 js.OpenObject(); 247 js.OpenObject();
228 js.PrintProperty("object_key", Object::Handle(Object::null())); 248 js.PrintProperty("object_key", Object::Handle(Object::null()));
229 js.CloseArray(); 249 js.CloseArray();
230 EXPECT_STREQ("[{\"type\":\"null\"},{\"object_key\":{\"type\":\"null\"}]", 250 EXPECT_STREQ("[{\"type\":\"null\"},{\"object_key\":{\"type\":\"null\"}]",
231 tb.buf()); 251 tb.buf());
232 } 252 }
233 253
234 254
235 } // namespace dart 255 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698