File Coverage

blib/lib/Mail/Message/Test.pm
Criterion Covered Total %
statement 33 34 97.0
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 0 2 0.0
total 44 48 91.6


line stmt bran cond sub pod time code
1             # This code is part of Perl distribution Mail-Message version 4.04.
2             # The POD got stripped from this file by OODoc version 3.06.
3             # For contributors see file ChangeLog.
4              
5             # This software is copyright (c) 2001-2026 by Mark Overmeer.
6              
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10              
11              
12             package Mail::Message::Test;{
13             our $VERSION = '4.04';
14             }
15              
16 54     54   328698 use parent 'Exporter';
  54         19882  
  54         353  
17              
18 54     54   5298 use strict;
  54         175  
  54         1682  
19 54     54   307 use warnings;
  54         112  
  54         3312  
20              
21 54     54   33370 use Log::Report 'mail-message', import => [ qw// ];
  54         5277283  
  54         391  
22              
23 54     54   33237 use File::Copy qw/copy/;
  54         244793  
  54         7645  
24 54     54   437 use List::Util qw/first/;
  54         101  
  54         3803  
25 54     54   29631 use IO::File; # to overrule open()
  54         425950  
  54         8181  
26 54     54   38467 use Test::More;
  54         6394736  
  54         694  
27              
28             our @EXPORT = qw/compare_message_prints reproducable_text $raw_html_data $crlf_platform/;
29             our $crlf_platform = $^O =~ m/mswin32/i;
30              
31             #
32             # Compare the text of two messages, rather strict.
33             # On CRLF platforms, the Content-Length may be different.
34             #
35              
36             sub compare_message_prints($$$)
37 8     8 0 61 { my ($first, $second, $label) = @_;
38              
39 8 50       25 if($crlf_platform)
40 0         0 { s/Content-Length: (\d+)/Content-Length: /g for $first, $second;
41             }
42              
43 8         63 is($first, $second, $label);
44             }
45              
46             #
47             # Strip message text down the things which are the same on all
48             # platforms and all situations.
49             #
50              
51             sub reproducable_text($)
52 4     4 0 14 { my $text = shift;
53 4         35 my @lines = split /^/m, $text;
54 4         13 foreach (@lines)
55 97         271 { s/((?:references|message-id|date|content-length)\: ).*/$1/i;
56 97         158 s/boundary-\d+/boundary-/g;
57             }
58 4         50 join '', @lines;
59             }
60              
61             #
62             # A piece of HTML text which is used in some tests.
63             #
64              
65             our $raw_html_data = <<'TEXT';
66            
67            
68             My home page
69            
70            
71              
72            

Life according to Brian

73              
74             This is normal text, but not in a paragraph.

New paragraph

75             in a bad way.
76              
77             And this is just a continuation. When texts get long, they must be
78             auto-wrapped; and even that is working already.
79              
80            

Silly subsection at once

81            

and another chapter

82            

again a section

83            

Normal paragraph, which contains an

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