| 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("dart:math"); | 5 #import("dart:math"); |
| 6 | 6 |
| 7 #source("../../../runtime/bin/input_stream.dart"); | 7 #source("../../../runtime/bin/input_stream.dart"); |
| 8 #source("../../../runtime/bin/output_stream.dart"); | 8 #source("../../../runtime/bin/output_stream.dart"); |
| 9 #source("../../../runtime/bin/chunked_stream.dart"); | 9 #source("../../../runtime/bin/chunked_stream.dart"); |
| 10 #source("../../../runtime/bin/string_stream.dart"); | 10 #source("../../../runtime/bin/string_stream.dart"); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 _HttpUtils.parseDate(" $valid"); | 78 _HttpUtils.parseDate(" $valid"); |
| 79 }); | 79 }); |
| 80 Expect.throws(() { | 80 Expect.throws(() { |
| 81 _HttpUtils.parseDate(" $valid "); | 81 _HttpUtils.parseDate(" $valid "); |
| 82 }); | 82 }); |
| 83 Expect.throws(() { | 83 Expect.throws(() { |
| 84 _HttpUtils.parseDate("$valid "); | 84 _HttpUtils.parseDate("$valid "); |
| 85 }); | 85 }); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void testParseHttpCookieDate() { |
| 89 Expect.throws(() => _HttpUtils.parseCookieDate("")); |
| 90 |
| 91 test(int year, |
| 92 int month, |
| 93 int day, |
| 94 int hours, |
| 95 int minutes, |
| 96 int seconds, |
| 97 String formatted) { |
| 98 Date date = new Date( |
| 99 year, month, day, hours, minutes, seconds, 0, isUtc: true); |
| 100 Expect.equals(date, _HttpUtils.parseCookieDate(formatted)); |
| 101 } |
| 102 |
| 103 test(2012, Date.JUN, 19, 14, 15, 01, "tue, 19-jun-12 14:15:01 gmt"); |
| 104 test(2021, Date.JUN, 09, 10, 18, 14, "Wed, 09-Jun-2021 10:18:14 GMT"); |
| 105 test(2021, Date.JAN, 13, 22, 23, 01, "Wed, 13-Jan-2021 22:23:01 GMT"); |
| 106 test(2013, Date.JAN, 15, 21, 47, 38, "Tue, 15-Jan-2013 21:47:38 GMT"); |
| 107 test(1970, Date.JAN, 01, 00, 00, 01, "Thu, 01-Jan-1970 00:00:01 GMT"); |
| 108 } |
| 109 |
| 88 void main() { | 110 void main() { |
| 89 testParseHttpDate(); | 111 testParseHttpDate(); |
| 90 testFormatParseHttpDate(); | 112 testFormatParseHttpDate(); |
| 91 testParseHttpDateFailures(); | 113 testParseHttpDateFailures(); |
| 114 testParseHttpCookieDate(); |
| 92 } | 115 } |
| OLD | NEW |