File: 10field.t

package info (click to toggle)
libmail-box-perl 2.068-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,576 kB
  • ctags: 1,493
  • sloc: perl: 22,358; makefile: 49
file content (67 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -T
#
# Test processing of header-fields: only single fields, not whole headers.
# This also doesn't cover reading headers from file.
#

use strict;
use warnings;

use lib qw(. .. tests);
use Tools;

use Test::More tests => 15;

use Mail::Message::Field;
use Mail::Box::Parser::Perl;

# Explictly ask for the Perl parser to fold lines.

Mail::Box::Parser->defaultParserType('Mail::Box::Parser::Perl');

#
# Processing of structured lines.
#

my $f = Mail::Message::Field->new('Sender:  B ;  C');
is($f->name, 'sender');
is($f->body, 'B');
like($f->comment , qr/^\s*C\s*/);

# No comment, strip CR LF

my $g = Mail::Message::Field->new("Sender: B\015\012");
is($g->body, 'B');
is($g->comment, "");

# Check toString

my $x = $f->toString;
is($x, "Sender: B ;  C\n");

$x = $g->toString;
is($x, "Sender: B\n");

# Now check folding.

my $k = Mail::Message::Field->new(Sender => 'short line');
is($k->toString, "Sender: short line\n");
my @klines = $k->toString;
cmp_ok(@klines, "==", 1);

my $long = 'oijfjslkgjhius2rehtpo2uwpefnwlsjfh2oireuqfqlkhfjowtropqhflksjhflkjhoiewurpq';
my $l = Mail::Message::Field->new(Sender => $long);
my @llines = $l->toString;
cmp_ok(@llines, "==", 1);

my $m = Mail::Message::Field->new(Sender =>
  'roijfjslkgjhiu, rehtpo2uwpe, fnwlsjfh2oire, uqfqlkhfjowtrop, qhflksjhflkj, hoiewurpq');

cmp_ok($m->nrLines, "==", 2);
$m->setWrapLength(35);
cmp_ok($m->nrLines, "==", 3);

my @mlines = $m->toString(72);
cmp_ok(@mlines, "==", 2);
is($mlines[0], "Sender: roijfjslkgjhiu, rehtpo2uwpe, fnwlsjfh2oire, uqfqlkhfjowtrop,\n");
is($mlines[1], " qhflksjhflkj, hoiewurpq\n");