File: 320bodyconv-textaf.t

package info (click to toggle)
libmail-message-perl 3.017-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,632 kB
  • sloc: perl: 11,156; makefile: 4
file content (54 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env perl
#
# Test formatting as plain text with Text::Autoformat
#

use strict;
use warnings;

use Mail::Message::Test;
use Mail::Message::Body;

use Test::More;

BEGIN {
    eval 'require Text::Autoformat';
    if($@)
    {   plan skip_all => "requires Text::Autoformat.";
        exit 0;
    }

    require Mail::Message::Convert::TextAutoformat;
    require Text::Autoformat;
    Text::Autoformat->import('break_wrap');

    plan tests => 3;
}

my $content = <<'TEXT';
This is some raw text to form the body of the
message which has to be printed.  I hope it is nice.
> some badly formatted
>    input lines
>  are also in here, to test whether autoformat works.... This line is for instance much too long and should be spread over multiple lines.
TEXT

my $body = Mail::Message::Body->new
 ( type  => 'text/html'
 , data  => $content
 );

my $af = Mail::Message::Convert::TextAutoformat
  ->new( options => {break => break_wrap} );
ok($af);

my $dump = $af->autoformatBody($body);
ok(defined $dump);

is("$dump", <<'DUMP');
This is some raw text to form the body of the message which has to be
printed. I hope it is nice.
> some badly formatted input lines are also in here, to test whether
> autoformat works.... This line is for instance much too long and
> should be spread over multiple lines.
DUMP