OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Tests for the strict option when parsing dates and times, which are | 5 /// Tests for the strict option when parsing dates and times, which are |
6 /// relatively locale-independent, depending only on the being a valid date | 6 /// relatively locale-independent, depending only on the being a valid date |
7 /// and consuming all the input data. | 7 /// and consuming all the input data. |
8 library date_time_strict_test; | 8 library date_time_strict_test; |
9 | 9 |
10 import 'package:intl/intl.dart'; | 10 import 'package:intl/intl.dart'; |
11 import 'package:unittest/unittest.dart'; | 11 import 'package:test/test.dart'; |
12 | 12 |
13 main() { | 13 main() { |
14 test("All input consumed", () { | 14 test("All input consumed", () { |
15 var format = new DateFormat.yMMMd(); | 15 var format = new DateFormat.yMMMd(); |
16 var date = new DateTime(2014, 9, 3); | 16 var date = new DateTime(2014, 9, 3); |
17 var formatted = 'Sep 3, 2014'; | 17 var formatted = 'Sep 3, 2014'; |
18 expect(format.format(date), formatted); | 18 expect(format.format(date), formatted); |
19 var parsed = format.parseStrict(formatted); | 19 var parsed = format.parseStrict(formatted); |
20 expect(parsed, date); | 20 expect(parsed, date); |
21 | 21 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 check("25:00:00"); | 70 check("25:00:00"); |
71 check("0:-1:00"); | 71 check("0:-1:00"); |
72 check("0:60:00"); | 72 check("0:60:00"); |
73 expect(format.parseStrict("0:59:00"), new DateTime(1970, 1, 1, 0, 59)); | 73 expect(format.parseStrict("0:59:00"), new DateTime(1970, 1, 1, 0, 59)); |
74 check("0:0:-1"); | 74 check("0:0:-1"); |
75 check("0:0:60"); | 75 check("0:0:60"); |
76 check("14:0:60"); | 76 check("14:0:60"); |
77 expect(format.parseStrict("14:0:59"), new DateTime(1970, 1, 1, 14, 0, 59)); | 77 expect(format.parseStrict("14:0:59"), new DateTime(1970, 1, 1, 14, 0, 59)); |
78 }); | 78 }); |
79 } | 79 } |
OLD | NEW |