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

Unified Diff: pkg/http_parser/test/http_date_test.dart

Issue 278783002: pkg/http_parser: fixed edge cases with 9s and single-digit days (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« pkg/http_parser/lib/src/http_date.dart ('K') | « pkg/http_parser/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http_parser/test/http_date_test.dart
diff --git a/pkg/http_parser/test/http_date_test.dart b/pkg/http_parser/test/http_date_test.dart
index 680147a08761dc14bb82e9f14ecff1d13774fb63..303d6d76d0e699119dd8fae7546a4f878a3fdf41 100644
--- a/pkg/http_parser/test/http_date_test.dart
+++ b/pkg/http_parser/test/http_date_test.dart
@@ -8,6 +8,38 @@ import 'package:http_parser/http_parser.dart';
import 'package:unittest/unittest.dart';
void main() {
+ group('format', () {
+ test('many values with 9', () {
+ var date = new DateTime.utc(2014, 9, 9, 9, 9, 9);
+ var formatted = formatHttpDate(date);
+
+ expect(formatted, 'Tue, 09 Sep 2014 09:09:09 GMT');
+ var parsed = parseHttpDate(formatted);
+
+ expect(parsed, date);
+ });
+
+ test('end of year', () {
+ var date = new DateTime.utc(1999, 12, 31, 23, 59, 59);
+ var formatted = formatHttpDate(date);
+
+ expect(formatted, 'Fri, 31 Dec 1999 23:59:59 GMT');
+ var parsed = parseHttpDate(formatted);
+
+ expect(parsed, date);
+ });
+
+ test('start of year', () {
+ var date = new DateTime.utc(2000, 1, 1, 0, 0, 0);
+ var formatted = formatHttpDate(date);
+
+ expect(formatted, 'Sat, 01 Jan 2000 00:00:00 GMT');
+ var parsed = parseHttpDate(formatted);
+
+ expect(parsed, date);
+ });
+ });
+
group("parse", () {
group("RFC 1123", () {
test("parses the example date", () {
« pkg/http_parser/lib/src/http_date.dart ('K') | « pkg/http_parser/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698