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

Side by Side Diff: tests/standalone/io/http_date_test.dart

Issue 13841005: Rename DateTime constants to full names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « tests/standalone/io/http_advanced_test.dart ('k') | tests/standalone/io/http_headers_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
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 8
9 part "../../../sdk/lib/io/io_sink.dart"; 9 part "../../../sdk/lib/io/io_sink.dart";
10 part "../../../sdk/lib/io/http.dart"; 10 part "../../../sdk/lib/io/http.dart";
11 part "../../../sdk/lib/io/http_impl.dart"; 11 part "../../../sdk/lib/io/http_impl.dart";
12 part "../../../sdk/lib/io/http_parser.dart"; 12 part "../../../sdk/lib/io/http_parser.dart";
13 part "../../../sdk/lib/io/http_utils.dart"; 13 part "../../../sdk/lib/io/http_utils.dart";
14 part "../../../sdk/lib/io/socket.dart"; 14 part "../../../sdk/lib/io/socket.dart";
15 15
16 void testParseHttpDate() { 16 void testParseHttpDate() {
17 DateTime date; 17 DateTime date;
18 date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); 18 date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
19 Expect.equals(date, _HttpUtils.parseDate("Fri, 11 Jun 1999 18:46:53 GMT")); 19 Expect.equals(date, _HttpUtils.parseDate("Fri, 11 Jun 1999 18:46:53 GMT"));
20 Expect.equals(date, _HttpUtils.parseDate("Friday, 11-Jun-1999 18:46:53 GMT")); 20 Expect.equals(date, _HttpUtils.parseDate("Friday, 11-Jun-1999 18:46:53 GMT"));
21 Expect.equals(date, _HttpUtils.parseDate("Fri Jun 11 18:46:53 1999")); 21 Expect.equals(date, _HttpUtils.parseDate("Fri Jun 11 18:46:53 1999"));
22 22
23 date = new DateTime.utc(1970, DateTime.JAN, 1, 0, 0, 0, 0); 23 date = new DateTime.utc(1970, DateTime.JANUARY, 1, 0, 0, 0, 0);
24 Expect.equals(date, _HttpUtils.parseDate("Thu, 1 Jan 1970 00:00:00 GMT")); 24 Expect.equals(date, _HttpUtils.parseDate("Thu, 1 Jan 1970 00:00:00 GMT"));
25 Expect.equals(date, 25 Expect.equals(date,
26 _HttpUtils.parseDate("Thursday, 1-Jan-1970 00:00:00 GMT")); 26 _HttpUtils.parseDate("Thursday, 1-Jan-1970 00:00:00 GMT"));
27 Expect.equals(date, _HttpUtils.parseDate("Thu Jan 1 00:00:00 1970")); 27 Expect.equals(date, _HttpUtils.parseDate("Thu Jan 1 00:00:00 1970"));
28 28
29 date = new DateTime.utc(2012, DateTime.MAR, 5, 23, 59, 59, 0); 29 date = new DateTime.utc(2012, DateTime.MARCH, 5, 23, 59, 59, 0);
30 Expect.equals(date, _HttpUtils.parseDate("Mon, 5 Mar 2012 23:59:59 GMT")); 30 Expect.equals(date, _HttpUtils.parseDate("Mon, 5 Mar 2012 23:59:59 GMT"));
31 Expect.equals(date, _HttpUtils.parseDate("Monday, 5-Mar-2012 23:59:59 GMT")); 31 Expect.equals(date, _HttpUtils.parseDate("Monday, 5-Mar-2012 23:59:59 GMT"));
32 Expect.equals(date, _HttpUtils.parseDate("Mon Mar 5 23:59:59 2012")); 32 Expect.equals(date, _HttpUtils.parseDate("Mon Mar 5 23:59:59 2012"));
33 } 33 }
34 34
35 void testFormatParseHttpDate() { 35 void testFormatParseHttpDate() {
36 test(int year, 36 test(int year,
37 int month, 37 int month,
38 int day, 38 int day,
39 int hours, 39 int hours,
40 int minutes, 40 int minutes,
41 int seconds, 41 int seconds,
42 String expectedFormatted) { 42 String expectedFormatted) {
43 DateTime date; 43 DateTime date;
44 String formatted; 44 String formatted;
45 date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0); 45 date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0);
46 formatted = _HttpUtils.formatDate(date); 46 formatted = _HttpUtils.formatDate(date);
47 Expect.equals(expectedFormatted, formatted); 47 Expect.equals(expectedFormatted, formatted);
48 Expect.equals(date, _HttpUtils.parseDate(formatted)); 48 Expect.equals(date, _HttpUtils.parseDate(formatted));
49 } 49 }
50 50
51 test(1999, DateTime.JUN, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT"); 51 test(1999, DateTime.JUNE, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT");
52 test(1970, DateTime.JAN, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT"); 52 test(1970, DateTime.JANUARY, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT");
53 test(2012, DateTime.MAR, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT"); 53 test(2012, DateTime.MARCH, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT");
54 } 54 }
55 55
56 void testParseHttpDateFailures() { 56 void testParseHttpDateFailures() {
57 Expect.throws(() { 57 Expect.throws(() {
58 _HttpUtils.parseDate(""); 58 _HttpUtils.parseDate("");
59 }); 59 });
60 String valid = "Mon, 5 Mar 2012 23:59:59 GMT"; 60 String valid = "Mon, 5 Mar 2012 23:59:59 GMT";
61 for (int i = 1; i < valid.length - 1; i++) { 61 for (int i = 1; i < valid.length - 1; i++) {
62 String tmp = valid.substring(0, i); 62 String tmp = valid.substring(0, i);
63 Expect.throws(() { 63 Expect.throws(() {
(...skipping 27 matching lines...) Expand all
91 int month, 91 int month,
92 int day, 92 int day,
93 int hours, 93 int hours,
94 int minutes, 94 int minutes,
95 int seconds, 95 int seconds,
96 String formatted) { 96 String formatted) {
97 DateTime date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0); 97 DateTime date = new DateTime.utc(year, month, day, hours, minutes, seconds, 0);
98 Expect.equals(date, _HttpUtils.parseCookieDate(formatted)); 98 Expect.equals(date, _HttpUtils.parseCookieDate(formatted));
99 } 99 }
100 100
101 test(2012, DateTime.JUN, 19, 14, 15, 01, "tue, 19-jun-12 14:15:01 gmt"); 101 test(2012, DateTime.JUNE, 19, 14, 15, 01, "tue, 19-jun-12 14:15:01 gmt");
102 test(2021, DateTime.JUN, 09, 10, 18, 14, "Wed, 09-Jun-2021 10:18:14 GMT"); 102 test(2021, DateTime.JUNE, 09, 10, 18, 14, "Wed, 09-Jun-2021 10:18:14 GMT");
103 test(2021, DateTime.JAN, 13, 22, 23, 01, "Wed, 13-Jan-2021 22:23:01 GMT"); 103 test(2021, DateTime.JANUARY, 13, 22, 23, 01, "Wed, 13-Jan-2021 22:23:01 GMT");
104 test(2013, DateTime.JAN, 15, 21, 47, 38, "Tue, 15-Jan-2013 21:47:38 GMT"); 104 test(2013, DateTime.JANUARY, 15, 21, 47, 38, "Tue, 15-Jan-2013 21:47:38 GMT");
105 test(1970, DateTime.JAN, 01, 00, 00, 01, "Thu, 01-Jan-1970 00:00:01 GMT"); 105 test(1970, DateTime.JANUARY, 01, 00, 00, 01, "Thu, 01-Jan-1970 00:00:01 GMT");
106 } 106 }
107 107
108 void main() { 108 void main() {
109 testParseHttpDate(); 109 testParseHttpDate();
110 testFormatParseHttpDate(); 110 testFormatParseHttpDate();
111 testParseHttpDateFailures(); 111 testParseHttpDateFailures();
112 testParseHttpCookieDate(); 112 testParseHttpCookieDate();
113 } 113 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_advanced_test.dart ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698