File: 02encode.t

package info (click to toggle)
libmime-encwords-perl 1.010.101-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 176 kB
  • ctags: 17
  • sloc: perl: 599; makefile: 41
file content (43 lines) | stat: -rw-r--r-- 946 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strict;
use Test;

BEGIN { plan tests => ($] >= 5.008001)? 26: 12 }

use MIME::EncWords qw(encode_mimewords);
$MIME::EncWords::Config = {
    Detect7bit => 'YES',
    Mapping => 'EXTENDED',
    Replacement => 'DEFAULT',
    Charset => 'ISO-8859-1',
    Encoding => 'A',
    Field => undef,
    Folding => "\n",
    MaxLineLen => 76,
    Minimal => 'YES',
};

my @testins = MIME::Charset::USE_ENCODE?
	      qw(encode-singlebyte encode-multibyte encode-ascii):
	      qw(encode-singlebyte);

{
  local($/) = '';
  foreach my $in (@testins) {
    open WORDS, "<testin/$in.txt" or die "open: $!";
    while (<WORDS>) {
	s{\A\s+|\s+\Z}{}g;    # trim

	my ($isgood, $dec, $expect) = split /\n/, $_, 3;
	$isgood = (uc($isgood) eq 'GOOD');
	my @params = eval $dec;

	my $enc = encode_mimewords(@params);
	ok((($isgood && !$@) or (!$isgood && $@)) &&
           ($isgood ? $enc : $expect), $expect, $@ || $enc);
    }
    close WORDS;
  }
}    

1;