File Coverage

blib/lib/Mail/Message/Test.pm
Criterion Covered Total %
statement 42 44 95.4
branch 1 2 50.0
condition n/a
subroutine 13 13 100.0
pod 0 2 0.0
total 56 61 91.8


line stmt bran cond sub pod time code
1             # Copyrights 2001-2022 by [Mark Overmeer ].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.03.
5             # This code is part of distribution Mail-Message. Meta-POD processed with
6             # OODoc into POD and HTML manual-pages. See README.md
7             # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8              
9             package Mail::Message::Test;
10 53     53   26028 use vars '$VERSION';
  53         294  
  53         3341  
11             $VERSION = '3.012';
12              
13 53     53   312 use base 'Exporter';
  53         94  
  53         6259  
14              
15 53     53   323 use strict;
  53         97  
  53         1125  
16 53     53   229 use warnings;
  53         85  
  53         1578  
17              
18 53     53   17053 use File::Copy 'copy';
  53         176548  
  53         3984  
19 53     53   390 use List::Util 'first';
  53         93  
  53         5030  
20 53     53   22824 use IO::File; # to overrule open()
  53         315044  
  53         5308  
21 53     53   395 use File::Spec;
  53         1870  
  53         2694  
22 53     53   249 use Cwd qw(getcwd);
  53         1998  
  53         9083  
23 53     53   25952 use Sys::Hostname qw(hostname);
  53         48114  
  53         3888  
24 53     53   40043 use Test::More;
  53         2936953  
  53         495  
25              
26              
27             our @EXPORT =
28             qw/compare_message_prints reproducable_text
29             $raw_html_data
30             $crlf_platform
31             /;
32              
33             our $crlf_platform = $^O =~ m/mswin32/i;
34              
35             #
36             # Compare the text of two messages, rather strict.
37             # On CRLF platforms, the Content-Length may be different.
38             #
39              
40             sub compare_message_prints($$$)
41 8     8 0 47 { my ($first, $second, $label) = @_;
42              
43 8 50       24 if($crlf_platform)
44 0         0 { $first =~ s/Content-Length: (\d+)/Content-Length: /g;
45 0         0 $second =~ s/Content-Length: (\d+)/Content-Length: /g;
46             }
47              
48 8         35 is($first, $second, $label);
49             }
50              
51             #
52             # Strip message text down the things which are the same on all
53             # platforms and all situations.
54             #
55              
56             sub reproducable_text($)
57 4     4 0 8 { my $text = shift;
58 4         29 my @lines = split /^/m, $text;
59 4         11 foreach (@lines)
60 97         228 { s/((?:references|message-id|date|content-length)\: ).*/$1/i;
61 97         153 s/boundary-\d+/boundary-/g;
62             }
63 4         39 join '', @lines;
64             }
65              
66             #
67             # A piece of HTML text which is used in some tests.
68             #
69              
70             our $raw_html_data = <<'TEXT';
71            
72            
73             My home page
74            
75            
76              
77            

Life according to Brian

78              
79             This is normal text, but not in a paragraph.

New paragraph

80             in a bad way.
81              
82             And this is just a continuation. When texts get long, they must be
83             auto-wrapped; and even that is working already.
84              
85            

Silly subsection at once

86            

and another chapter

87            

again a section

88            

Normal paragraph, which contains an

89             SRC=image.gif>, some
90             italics with linebreak
91             and code
92              
93            
 
94             And now for the preformatted stuff
95             it should stay as it was
96             even with strange blanks
97             and indentations
98            
99              
100             And back to normal text...
101            
102            
  • list item 1
  • 103            
    104            
  • list item 1.1
  • 105            
  • list item 1.2
  • 106            
    107            
  • list item 2
  • 108            
    109            
    110            
    111             TEXT
    112              
    113             1;