File: above-0xFF.t

package info (click to toggle)
libemail-simple-perl 2.218-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 462; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 1,546 bytes parent folder | download
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
use v5.12.0;
use warnings;

use Test::More tests => 7;
use Email::Simple;

sub get_warning(&) {
  my $message;
  local $SIG{__WARN__} = sub { $message = $_[0] unless $message };
  $_[0]->();
  return $message;
}

like get_warning { Email::Simple->new("\N{U+100}: \N{U+100}") }, qr/^Message with wide characters at $0 /, 'Email::Simple->new warns with characters above 0xFF';

like get_warning { Email::Simple->create(body => "\N{U+100}") }, qr/^Body with wide characters at $0 /, 'Email::Simple->create warns with characters above 0xFF in body';

like get_warning { Email::Simple->create(header => [ "\N{U+100}" => "a" ]) }, qr/^Header name '\N{U+100}' with wide characters at $0 /, 'Email::Simple->create warns with characters above 0xFF in header name';

like get_warning { Email::Simple->create(header => [ a => "\N{U+100}" ]) }, qr/^Value '\N{U+100}' for 'a' header with wide characters at $0 /, 'Email::Simple->create warns with characters above 0xFF in header value';

my $m = Email::Simple->create();

like get_warning { $m->body_set("\N{U+100}") }, qr/^Body with wide characters at $0 /, 'Email::Simple->header_set warns with characters above 0xFF in body';

like get_warning { $m->header_set("\N{U+100}", "a") }, qr/^Header name '\N{U+100}' with wide characters at $0 /, 'Email::Simple->header_set warns with characters above 0xFF in header name';

like get_warning { $m->header_set("a", "\N{U+100}") }, qr/^Value for 'a' header with wide characters at $0 /, 'Email::Simple->header_set warns with characters above 0xFF in header value';