File: 311encode-eight.t

package info (click to toggle)
libmail-message-perl 3.017-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,632 kB
  • sloc: perl: 11,156; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (4)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
#
# Encoding and Decoding of 8bit
#

use strict;
use warnings;

use Mail::Message::Test;
use Mail::Message::Body::Lines;
use Mail::Message::TransferEnc::EightBit;

use Test::More tests => 6;

my $decoded = <<DECODED;
yefoiuhsjhkw284Ue\000iouoi\013wei
sdfuljlkjliua\000aba
DECODED

my $encoded = <<ENCODED;
yefoiuhsjhkw284Ueiouoiwei
sdfuljlkjliuaaba
ENCODED

my $codec = Mail::Message::TransferEnc::EightBit->new;
ok(defined $codec);
is($codec->name, '8bit');

# Test encoding

my $body   = Mail::Message::Body::Lines->new
  ( mime_type => 'text/html'
  , data      => $decoded
  );

my $enc    = $codec->encode($body);
ok($body!=$enc);
is($enc->mimeType, 'text/html');
is($enc->transferEncoding, '8bit');
is($enc->string, $encoded);

# Test decoding