summaryrefslogtreecommitdiff
path: root/cpan/dist/MIME-Lite/t/addrs.t
blob: d5758fa6935bac4136d12adf30afc8913771eb08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
use lib "lib", "t";
use MIME::Lite;
use ExtUtils::TBone;
use Utils;

# Make a tester... here are 3 different alternatives:
my $T = typical ExtUtils::TBone;                 # standard log
$MIME::Lite::VANILLA  = 1;
$MIME::Lite::PARANOID = 1;

# Pairs:
my @pairs = 
    (
     ['  me@myhost.com      ',
      1,
      '<me@myhost.com>'],

     ['  mylogin      ',
      1,
      '<mylogin>'],

     ['   "Me, Jr." <  me@myhost.com >  ',
      1,
      '<me@myhost.com>'],

     ['  Me   <me@myhost.com>',
      1,
      '<me@myhost.com>'],

     ['"Me, Jr." <me@myhost.com>',
      1,
      '<me@myhost.com>'],

     ['"Me@somewhere.com, Jr." <me@myhost.com>',
      1,
      '<me@myhost.com>'],

     ['me@myhost.com,you@yourhost.com',
      2,
      '<me@myhost.com> <you@yourhost.com>'],

     ['"Me" <me@myhost.com>, "You"<you@yourhost.com>',
      2,
      '<me@myhost.com> <you@yourhost.com>'],

     ['"Me" <me@myhost.com>, you@yourhost.com, "And also" <she@herhost.com>',
      3,
      '<me@myhost.com> <you@yourhost.com> <she@herhost.com>'],

     ['"Me" <me@myhost.com>, mylogin  ,yourlogin  , She <she@herhost.com>',
      4,
      '<me@myhost.com> <mylogin> <yourlogin> <she@herhost.com>']
     );
      

# Abort?
if (eval "require Mail::Address") {
    $T->begin(1);
    $T->ok(1, "we have and trust Mail::Address");
    $T->end;
    exit 0;
}  

# Begin testing:
$T->begin(2 * @pairs);

# New:
foreach my $pair (@pairs) {
    my ($to, $count, $result) = @$pair;
    my @addrs = MIME::Lite::extract_addrs($to);

    $T->ok_eqnum(int(@addrs), $count,
                 "compare count",
		 In => $to);
    $T->ok_eq(join(' ', map {"<$_>"} @addrs),
	      $result,
	      "compare result",
	      In => $to);
}

$T->end;