1#!perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use HTTP::Tiny;
8
9# test cases adapted from HTTP::Date
10my $epoch = 760233600;
11
12my @cases = (
13  ['Thu, 03 Feb 1994 00:00:00 GMT',       'RFC822+RFC1123'],
14  ['Thu,  3 Feb 1994 00:00:00 GMT',       'broken RFC822+RFC1123'],
15  ['Thursday, 03-Feb-94 00:00:00 GMT',    'old rfc850 HTTP format'],
16  ['Thursday, 03-Feb-1994 00:00:00 GMT',  'broken rfc850 HTTP format'],
17  ['Thu Feb  3 00:00:00 GMT 1994',        'ctime format'],
18  ['Thu Feb  3 00:00:00 1994',            'same as ctime, except no TZ'],
19);
20
21plan tests => 1 + @cases;
22
23is(HTTP::Tiny->_http_date($epoch), $cases[0][0], "epoch -> RFC822/RFC1123");
24
25for my $c ( @cases ) {
26  is( HTTP::Tiny->_parse_http_date($c->[0]), $epoch, $c->[1] . " -> epoch");
27}
28
29
30