| 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 25 matching lines...) Expand all Loading... |
| 36 String expectedFormatted) { | 36 String expectedFormatted) { |
| 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, 01 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(1970, DateTime.JANUARY, 1, 9, 9, 9, "Thu, 01 Jan 1970 09:09:09 GMT"); |
| 48 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, 05 Mar 2012 23:59:59 GMT"); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void testParseHttpDateFailures() { | 51 void testParseHttpDateFailures() { |
| 52 Expect.throws(() { | 52 Expect.throws(() { |
| 53 HttpDate.parse(""); | 53 HttpDate.parse(""); |
| 54 }); | 54 }); |
| 55 String valid = "Mon, 5 Mar 2012 23:59:59 GMT"; | 55 String valid = "Mon, 5 Mar 2012 23:59:59 GMT"; |
| 56 for (int i = 1; i < valid.length - 1; i++) { | 56 for (int i = 1; i < valid.length - 1; i++) { |
| 57 String tmp = valid.substring(0, i); | 57 String tmp = valid.substring(0, i); |
| 58 Expect.throws(() { | 58 Expect.throws(() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 Expect.throws(() { | 77 Expect.throws(() { |
| 78 HttpDate.parse("$valid "); | 78 HttpDate.parse("$valid "); |
| 79 }); | 79 }); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void main() { | 82 void main() { |
| 83 testParseHttpDate(); | 83 testParseHttpDate(); |
| 84 testFormatParseHttpDate(); | 84 testFormatParseHttpDate(); |
| 85 testParseHttpDateFailures(); | 85 testParseHttpDateFailures(); |
| 86 } | 86 } |
| OLD | NEW |