Debian Codegraph @

t/basic.t

raw
1 use Test::More tests => 12;
2 use_ok("Email::MIME::Encodings");
3
4 my $CRLF = "\x0d\x0a";
5 my $x = "This is a test${CRLF}of various MIME=stuff.";
6 for (qw(binary 7bit 8bit)) {
7 is(Email::MIME::Encodings::encode($_, $x), $x, "enc $_");
8 is(Email::MIME::Encodings::decode($_, $x), $x, "dec $_");
9 }
10
11 $y = "This is a test${CRLF}of various MIME=3Dstuff.=${CRLF}";
12 is(Email::MIME::Encodings::encode(quotedprint => $x), $y, "enc qp");
13 is(Email::MIME::Encodings::decode(quotedprint => $y), $x, "dec qp");
14
15 $z = "VGhpcyBpcyBhIHRlc3QNCm9mIHZhcmlvdXMgTUlNRT1zdHVmZi4=${CRLF}";
16 is(Email::MIME::Encodings::encode(base64 => $x), $z, "enc 64");
17 is(Email::MIME::Encodings::decode(base64 => $z), $x, "dec 64");
18
19 eval {
20 Email::MIME::Encodings::encode(foo => $x);
21 };
22
23 like ($@, qr/how to encode foo/, "Error handling");