File: internet.t

package info (click to toggle)
libmailtools-perl 2.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: perl: 2,224; makefile: 18
file content (60 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (11)
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
#!perl -w

require Mail::Internet;
use Config;

$ENV{LOGNAME} ||= 'unknown';

print "1..3\n";
$|=1;

$head = <<EOF;
From from_\@localhost
To: Some perl administrator <$Config{perladmin}>
From: Somebody <$ENV{LOGNAME}\@localhost>
Subject: Mail::Internet test subject
EOF

$body = <<EOF;
This is a test message that was sent by the test suite of
Mail::Internet.

Testing.

one

From foo
four

>From bar
seven
EOF

$mail = "$head\n$body";
($mbox = $mail) =~ s/^(>*)From /$1>From /gm;
$mbox =~ s/^>From /From / or die;
$mbox .= "\n";
@mail = map { "$_\n" } split /\n/, $mail;

sub ok {
    my ($n, $result, @info) = @_;
    if ($result) {
    	print "ok $n\n";
    }
    else {
    	for (@info) {
	    s/^/# /mg;
	}
    	print "not ok $n\n", @info;
	print "\n" if @info && $info[-1] !~ /\n$/;
    }
}

ok 1, $i = new Mail::Internet \@mail, Modify => 0;
ok 2, $i->as_string eq $mail, $i->as_string;
ok 3, $i->as_mbox_string eq $mbox, $i->as_mbox_string;
#ok 4, $i->send;