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

Side by Side Diff: tests/corelib/duration_test.dart

Issue 119263002: Fix bug in Duration.toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « sdk/lib/core/duration.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 main() { 7 main() {
8 Duration d; 8 Duration d;
9 d = new Duration(days: 1); 9 d = new Duration(days: 1);
10 Expect.equals(86400000000, d.inMicroseconds); 10 Expect.equals(86400000000, d.inMicroseconds);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 d = const Duration(hours: 1999, minutes: 17, seconds: 42); 219 d = const Duration(hours: 1999, minutes: 17, seconds: 42);
220 Expect.equals("1999:17:42.000000", d.toString()); 220 Expect.equals("1999:17:42.000000", d.toString());
221 221
222 d = const Duration(days: -1, hours: -3, minutes: -17, seconds: -42, 222 d = const Duration(days: -1, hours: -3, minutes: -17, seconds: -42,
223 milliseconds: -823, microseconds: -127); 223 milliseconds: -823, microseconds: -127);
224 Expect.equals("-27:17:42.823127", d.toString()); 224 Expect.equals("-27:17:42.823127", d.toString());
225 225
226 d = const Duration(hours: -1999, minutes: -17, seconds: -42); 226 d = const Duration(hours: -1999, minutes: -17, seconds: -42);
227 Expect.equals("-1999:17:42.000000", d.toString()); 227 Expect.equals("-1999:17:42.000000", d.toString());
228
229 // Edge conditions for toString of microseconds.
230 // Regression test for http://dartbug.com/15678
231
232 d = const Duration(microseconds: 1);
233 Expect.equals("0:00:00.000001", d.toString());
234
235 d = const Duration(microseconds: 9);
236 Expect.equals("0:00:00.000009", d.toString());
237
238 d = const Duration(microseconds: 10);
239 Expect.equals("0:00:00.000010", d.toString());
240
241 d = const Duration(microseconds: 99);
242 Expect.equals("0:00:00.000099", d.toString());
243
244 d = const Duration(microseconds: 100);
245 Expect.equals("0:00:00.000100", d.toString());
246
247 d = const Duration(microseconds: 999);
248 Expect.equals("0:00:00.000999", d.toString());
249
250 d = const Duration(microseconds: 1000);
251 Expect.equals("0:00:00.001000", d.toString());
252
253 d = const Duration(microseconds: 9999);
254 Expect.equals("0:00:00.009999", d.toString());
255
256 d = const Duration(microseconds: 10000);
257 Expect.equals("0:00:00.010000", d.toString());
258
259 d = const Duration(microseconds: 99999);
260 Expect.equals("0:00:00.099999", d.toString());
261
262 d = const Duration(microseconds: 100000);
263 Expect.equals("0:00:00.100000", d.toString());
264
265 d = const Duration(microseconds: 999999);
266 Expect.equals("0:00:00.999999", d.toString());
267
268 d = const Duration(microseconds: 1000000);
269 Expect.equals("0:00:01.000000", d.toString());
228 } 270 }
OLDNEW
« no previous file with comments | « sdk/lib/core/duration.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698