| 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-2021 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.02. | ||||||
| 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 | 31773 | use vars '$VERSION'; | |||
| 53 | 391 | ||||||
| 53 | 3964 | ||||||
| 11 | $VERSION = '3.011'; | ||||||
| 12 | |||||||
| 13 | 53 | 53 | 353 | use base 'Exporter'; | |||
| 53 | 108 | ||||||
| 53 | 7118 | ||||||
| 14 | |||||||
| 15 | 53 | 53 | 381 | use strict; | |||
| 53 | 106 | ||||||
| 53 | 1294 | ||||||
| 16 | 53 | 53 | 296 | use warnings; | |||
| 53 | 107 | ||||||
| 53 | 2413 | ||||||
| 17 | |||||||
| 18 | 53 | 53 | 21751 | use File::Copy 'copy'; | |||
| 53 | 191111 | ||||||
| 53 | 4875 | ||||||
| 19 | 53 | 53 | 439 | use List::Util 'first'; | |||
| 53 | 122 | ||||||
| 53 | 6207 | ||||||
| 20 | 53 | 53 | 28406 | use IO::File; # to overrule open() | |||
| 53 | 368819 | ||||||
| 53 | 6260 | ||||||
| 21 | 53 | 53 | 461 | use File::Spec; | |||
| 53 | 2740 | ||||||
| 53 | 3553 | ||||||
| 22 | 53 | 53 | 2258 | use Cwd qw(getcwd); | |||
| 53 | 3088 | ||||||
| 53 | 6444 | ||||||
| 23 | 53 | 53 | 31798 | use Sys::Hostname qw(hostname); | |||
| 53 | 60777 | ||||||
| 53 | 5252 | ||||||
| 24 | 53 | 53 | 41939 | use Test::More; | |||
| 53 | 3530305 | ||||||
| 53 | 569 | ||||||
| 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 | 49 | { my ($first, $second, $label) = @_; | ||
| 42 | |||||||
| 43 | 8 | 50 | 31 | if($crlf_platform) | |||
| 44 | 0 | 0 | { $first =~ s/Content-Length: (\d+)/Content-Length: |
||||
| 45 | 0 | 0 | $second =~ s/Content-Length: (\d+)/Content-Length: |
||||
| 46 | } | ||||||
| 47 | |||||||
| 48 | 8 | 38 | 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 | 11 | { my $text = shift; | ||
| 58 | 4 | 34 | my @lines = split /^/m, $text; | ||||
| 59 | 4 | 13 | foreach (@lines) | ||||
| 60 | 97 | 279 | { s/((?:references|message-id|date|content-length)\: ).*/$1 |
||||
| 61 | 97 | 185 | s/boundary-\d+/boundary- |
||||
| 62 | } | ||||||
| 63 | 4 | 53 | 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 | |
||||||
| 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 | |
||||||
| 103 | |
||||||
| 104 | |
||||||
| 105 | |
||||||
| 106 | |||||||
| 107 | |
||||||
| 108 | |||||||
| 109 | |||||||
| 110 | |||||||
| 111 | TEXT | ||||||
| 112 | |||||||
| 113 | 1; |