File: WordDecoder.t

package info (click to toggle)
libmime-tools-perl 5.428-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,604 kB
  • ctags: 525
  • sloc: perl: 6,454; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 18;

use MIME::QuotedPrint qw(decode_qp);
use MIME::WordDecoder;

my $mwd = (new MIME::WordDecoder::ISO_8859 1);
{
    local($/) = '';
    open WORDS, "<testin/words.txt" or die "open: $!";
    while (<WORDS>) {
	s{\A\s+|\s+\Z}{}g;    # trim

	my ($isgood, $expect, $enc) = split /\n/, $_, 3;

	# Create the expected data
	$expect = eval $expect;

	my $dec = $mwd->decode($enc);
	if( $isgood eq 'GOOD' ) {
		ok( ! $@, 'No exceptions');
		is( $dec, $expect, "$enc produced correct output");
	} else {
		ok( $@, 'Got an exception as expected');
	}

    }
    close WORDS;
}