OLD | NEW |
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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:async"; | 6 import "dart:async"; |
7 import "dart:math"; | 7 import "dart:math"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 void testParseHttpDate() { | 10 void testParseHttpDate() { |
(...skipping 26 matching lines...) Expand all Loading... |
37 DateTime date; | 37 DateTime date; |
38 String formatted; | 38 String formatted; |
39 date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0); | 39 date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0); |
40 formatted = HttpDate.format(date); | 40 formatted = HttpDate.format(date); |
41 Expect.equals(expectedFormatted, formatted); | 41 Expect.equals(expectedFormatted, formatted); |
42 Expect.equals(date, HttpDate.parse(formatted)); | 42 Expect.equals(date, HttpDate.parse(formatted)); |
43 } | 43 } |
44 | 44 |
45 test(1999, DateTime.JUNE, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT"); | 45 test(1999, DateTime.JUNE, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT"); |
46 test(1970, DateTime.JANUARY, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT"); | 46 test(1970, DateTime.JANUARY, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT"); |
| 47 test(1970, DateTime.JANUARY, 1, 9, 9, 9, "Thu, 1 Jan 1970 09:09:09 GMT"); |
47 test(2012, DateTime.MARCH, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT"); | 48 test(2012, DateTime.MARCH, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT"); |
48 } | 49 } |
49 | 50 |
50 void testParseHttpDateFailures() { | 51 void testParseHttpDateFailures() { |
51 Expect.throws(() { | 52 Expect.throws(() { |
52 HttpDate.parse(""); | 53 HttpDate.parse(""); |
53 }); | 54 }); |
54 String valid = "Mon, 5 Mar 2012 23:59:59 GMT"; | 55 String valid = "Mon, 5 Mar 2012 23:59:59 GMT"; |
55 for (int i = 1; i < valid.length - 1; i++) { | 56 for (int i = 1; i < valid.length - 1; i++) { |
56 String tmp = valid.substring(0, i); | 57 String tmp = valid.substring(0, i); |
(...skipping 19 matching lines...) Expand all Loading... |
76 Expect.throws(() { | 77 Expect.throws(() { |
77 HttpDate.parse("$valid "); | 78 HttpDate.parse("$valid "); |
78 }); | 79 }); |
79 } | 80 } |
80 | 81 |
81 void main() { | 82 void main() { |
82 testParseHttpDate(); | 83 testParseHttpDate(); |
83 testFormatParseHttpDate(); | 84 testFormatParseHttpDate(); |
84 testParseHttpDateFailures(); | 85 testParseHttpDateFailures(); |
85 } | 86 } |
OLD | NEW |