| 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-2023 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 | 55 | 55 | 29496 | use vars '$VERSION'; | |||
| 55 | 352 | ||||||
| 55 | 3871 | ||||||
| 11 | $VERSION = '3.013'; | ||||||
| 12 | |||||||
| 13 | 55 | 55 | 395 | use base 'Exporter'; | |||
| 55 | 101 | ||||||
| 55 | 6956 | ||||||
| 14 | |||||||
| 15 | 55 | 55 | 389 | use strict; | |||
| 55 | 123 | ||||||
| 55 | 1324 | ||||||
| 16 | 55 | 55 | 288 | use warnings; | |||
| 55 | 118 | ||||||
| 55 | 1922 | ||||||
| 17 | |||||||
| 18 | 55 | 55 | 21377 | use File::Copy 'copy'; | |||
| 55 | 195269 | ||||||
| 55 | 4581 | ||||||
| 19 | 55 | 55 | 440 | use List::Util 'first'; | |||
| 55 | 123 | ||||||
| 55 | 6092 | ||||||
| 20 | 55 | 55 | 26126 | use IO::File; # to overrule open() | |||
| 55 | 384722 | ||||||
| 55 | 6379 | ||||||
| 21 | 55 | 55 | 2034 | use File::Spec; | |||
| 55 | 1821 | ||||||
| 55 | 4324 | ||||||
| 22 | 55 | 55 | 1968 | use Cwd qw(getcwd); | |||
| 55 | 2437 | ||||||
| 55 | 7249 | ||||||
| 23 | 55 | 55 | 28142 | use Sys::Hostname qw(hostname); | |||
| 55 | 53021 | ||||||
| 55 | 4853 | ||||||
| 24 | 55 | 55 | 43347 | use Test::More; | |||
| 55 | 3541285 | ||||||
| 55 | 506 | ||||||
| 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 | 59 | { my ($first, $second, $label) = @_; | ||
| 42 | |||||||
| 43 | 8 | 50 | 21 | 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 | 28 | 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 | 9 | { my $text = shift; | ||
| 58 | 4 | 26 | my @lines = split /^/m, $text; | ||||
| 59 | 4 | 11 | foreach (@lines) | ||||
| 60 | 97 | 255 | { s/((?:references|message-id|date|content-length)\: ).*/$1 |
||||
| 61 | 97 | 186 | s/boundary-\d+/boundary- |
||||
| 62 | } | ||||||
| 63 | 4 | 38 | 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; |