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

Side by Side Diff: tests/corelib_strong/date_time4_test.dart

Issue 2984063002: Migrate test block 5 to Dart 2.0. (Closed)
Patch Set: merge with head Created 3 years, 5 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
« no previous file with comments | « tests/corelib_strong/date_time3_test.dart ('k') | tests/corelib_strong/date_time5_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 // Test fromString with 6 digits after the decimal point.
8
9 bool get supportsMicroseconds =>
10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
11
12 main() {
13 if (supportsMicroseconds) {
14 testMicrosecondPrecision();
15 } else {
16 testMillisecondPrecision();
17 }
18 }
19
20 void testMillisecondPrecision() {
21 // We only support milliseconds. If the user supplies more data (the "51"
22 // here), we round.
23 DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
24 Expect.equals(1999, dt1.year);
25 Expect.equals(1, dt1.month);
26 Expect.equals(3, dt1.day);
27 Expect.equals(0, dt1.hour);
28 Expect.equals(0, dt1.minute);
29 Expect.equals(0, dt1.second);
30 Expect.equals(0, dt1.millisecond);
31 Expect.equals(false, dt1.isUtc);
32 dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
33 Expect.equals(1999, dt1.year);
34 Expect.equals(1, dt1.month);
35 Expect.equals(2, dt1.day);
36 Expect.equals(23, dt1.hour);
37 Expect.equals(59, dt1.minute);
38 Expect.equals(0, dt1.second);
39 Expect.equals(0, dt1.millisecond);
40 Expect.equals(true, dt1.isUtc);
41 dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
42 Expect.equals(9, dt1.year);
43 Expect.equals(9, dt1.month);
44 Expect.equals(9, dt1.day);
45 Expect.equals(9, dt1.hour);
46 Expect.equals(9, dt1.minute);
47 Expect.equals(9, dt1.second);
48 Expect.equals(9, dt1.millisecond);
49 Expect.equals(true, dt1.isUtc);
50 String svnDate = "2012-03-30T04:28:13.752341Z";
51 dt1 = DateTime.parse(svnDate);
52 Expect.equals(2012, dt1.year);
53 Expect.equals(3, dt1.month);
54 Expect.equals(30, dt1.day);
55 Expect.equals(4, dt1.hour);
56 Expect.equals(28, dt1.minute);
57 Expect.equals(13, dt1.second);
58 Expect.equals(752, dt1.millisecond);
59 Expect.equals(true, dt1.isUtc);
60 }
61
62 void testMicrosecondPrecision() {
63 DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
64 Expect.equals(1999, dt1.year);
65 Expect.equals(1, dt1.month);
66 Expect.equals(2, dt1.day);
67 Expect.equals(23, dt1.hour);
68 Expect.equals(59, dt1.minute);
69 Expect.equals(59, dt1.second);
70 Expect.equals(999, dt1.millisecond);
71 Expect.equals(519, dt1.microsecond);
72 Expect.equals(false, dt1.isUtc);
73 dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
74 Expect.equals(1999, dt1.year);
75 Expect.equals(1, dt1.month);
76 Expect.equals(2, dt1.day);
77 Expect.equals(23, dt1.hour);
78 Expect.equals(58, dt1.minute);
79 Expect.equals(59, dt1.second);
80 Expect.equals(999, dt1.millisecond);
81 Expect.equals(519, dt1.microsecond);
82 Expect.equals(true, dt1.isUtc);
83 dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
84 Expect.equals(9, dt1.year);
85 Expect.equals(9, dt1.month);
86 Expect.equals(9, dt1.day);
87 Expect.equals(9, dt1.hour);
88 Expect.equals(9, dt1.minute);
89 Expect.equals(9, dt1.second);
90 Expect.equals(9, dt1.millisecond);
91 Expect.equals(411, dt1.microsecond);
92 Expect.equals(true, dt1.isUtc);
93 String svnDate = "2012-03-30T04:28:13.752341Z";
94 dt1 = DateTime.parse(svnDate);
95 Expect.equals(2012, dt1.year);
96 Expect.equals(3, dt1.month);
97 Expect.equals(30, dt1.day);
98 Expect.equals(4, dt1.hour);
99 Expect.equals(28, dt1.minute);
100 Expect.equals(13, dt1.second);
101 Expect.equals(752, dt1.millisecond);
102 Expect.equals(341, dt1.microsecond);
103 Expect.equals(true, dt1.isUtc);
104 }
OLDNEW
« no previous file with comments | « tests/corelib_strong/date_time3_test.dart ('k') | tests/corelib_strong/date_time5_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698