~ubuntu-branches/ubuntu/utopic/libdatetime-format-mail-perl/utopic-proposed

« back to all changes in this revision

Viewing changes to t/timezones.t

  • Committer: Bazaar Package Importer
  • Author(s): Jaldhar H. Vyas
  • Date: 2006-01-18 22:33:15 UTC
  • Revision ID: james.westby@ubuntu.com-20060118223315-cxvvqmhd8baiuwoo
Tags: upstream-0.2901
ImportĀ upstreamĀ versionĀ 0.2901

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use Test::More tests => 13;
 
3
use vars qw( $class );
 
4
BEGIN {
 
5
    $class = 'DateTime::Format::Mail';
 
6
    use_ok $class;
 
7
}
 
8
 
 
9
my $fn = sub {
 
10
    $class->determine_timezone( @_ );
 
11
};
 
12
 
 
13
my %testsuite = (
 
14
    'EDT translates' => { 'EDT' => '-0400' },
 
15
    '+0400 remains the same' => { '+0400' => '+0400' },
 
16
    'leading GMTs on valids stripped' => {
 
17
        'GMT+0300' => '+0300',
 
18
        'GMT-0300' => '-0300',
 
19
    },
 
20
    'slightly off forms' => {
 
21
        '400'   => '+0400',
 
22
        '-400'  => '-0400',
 
23
        '+400'  => '+0400',
 
24
    },
 
25
    'GMT normals' => {
 
26
        'GMT'   => '+0000',
 
27
        'UTC'   => '+0000',
 
28
    },
 
29
    'multiple signs' => {
 
30
        '+-700' => '-0700',
 
31
        '--700' => '-0700',
 
32
    },
 
33
    'invalids to -0000' => {
 
34
        'fnar'  => '-0000',
 
35
    },
 
36
);
 
37
 
 
38
for my $label (sort keys %testsuite)
 
39
{
 
40
    my $tests = $testsuite{$label};
 
41
    for my $input (sort keys %$tests)
 
42
    {
 
43
        my $expected = $tests->{$input};
 
44
        is $fn->( $input ) => $expected => "$label ($input)";
 
45
    }
 
46
}